View Full Version : navigate pages generated from the select query

07-02-2007, 12:24 PM
Mentioned below is a PHP function , which can be used to navigate pages generated from the select query . ie. in the form of << Previous || Next >>


function PagerNextPrevious(&$sql,$pagesize,$class='txt'){

// Set Default Page Size to 20
$rs=mysql_query($sql) ;
$sql=$sql." limit $beg,$end";

echo "( Page $page of $totalpages )&nbsp; &nbsp;&nbsp; ";
if($page>1 ){
echo "<a class=$class href='".selfq()."&page=".($page-1)."'> &lt;&lt;Previous </a>";
if($next <=$totalpages ){

echo "&nbsp;&nbsp;&nbsp;<a class=$class href='".selfq()."&page=".$next."'> Next &gt;&gt; </a>";


// Assuming you have Opened connection to mysql database.

$sql=" Select * from Products ";

// Show the pager link in form of Previous||Next


echo $row["ProductName"]."<br>";



Software Development India (http://www.hanusoftware.com)

07-02-2007, 02:30 PM
The proper place to post a code snippet is - http://www.codingforums.com/forumdisplay.php?f=41

When you post it in the PHP help forum, someone just thinks you need help with it but you forgot to post your question.

Also, if you are going to be posting code that you expect someone else to be able to read and use -

Wrap the code in PHP code tags so that it is readable/scrollable, use proper INDENTATION in your code, and use full <?php opening tags. More verbose comments that explain what each part of the code is and how it works would help make your code more readable and useful too.

11-04-2009, 10:57 AM
I have one question. I tried to use this code but I had problem could u help me ?:confused:there is selfq(). what is it, because when I wanna see the result there is an error for selfq()..
best regards.