Study

How to Create go to Next page or previous page in Php

In this article i am gone to share How to Create go to Next page or previous page in Php with you..

Also visit: How to get back your Domain

How to Create go to Next page or previous page in Php

 

For go on Previousย Post this SQL Query used

$id=5; 
select * from artical where id < '$id' order by id DESC LIMIT 1;

For go onย Next Post this SQL Query used

$id=5; 
select * from artical where id > '$id' order by id ASC LIMIT 1;

 

Implementationย in code…

For go on Previousย Post

$sql="select * from artical where id < '$id' order by id DESC LIMIT 1"; 
$result= mysqli_query($link, $sql); 
if(mysqli_num_rows($result)>0)
{ while($row = mysqli_fetch_assoc($resultpr))
{ $pr_id = $row['id']; $pr_title = $row['title']; 
echo ' <a href="post.php?artical_id='.$pr_id.'" > $pr_title</a> '; 
} 
}else{ echo '<span>No More Post</span>'; }

 

 

Next page or previous page in Php

Create Next page or previous page in Php

For go on Next Post

$sqln="select * from artical where id >'$id' order by id ASC LIMIT 1"; 
$resultn= mysqli_query($link, $sqln); 
if(mysqli_num_rows($resultn)>0) 
{ ย while($row = mysqli_fetch_assoc($resultn))
{ $nx_id = $row['id']; $nx_title = $row['title']; 
echo ' <a href="post.php?artical_id='.$nx_id.'" > $nx_title</a> '; 
} 
} else{ echo '<span>No More Post</span>'; 
}

Also There is two popular way to make browsers go back to the previous page by clicking JavaScript event, both methods are described below:

Method 1:

Using history.go() method: The go() method of the window.history object is used to load a page from the session history. It can be used to move forward or backward using the value of the delta parameter. A positive delta parameter means that the page would go forward in history. Similarly, a negative delta value would make the page go back to the previous page.
This method can be used with โ€˜-1โ€™ as the delta value to go back one page in history. The onclick event can be specified with the method to go back one page in history.

Syntax:

window.history.go(-1)