You didn't used the $offset value? and I think you dont have a LIMIT on your sql query. Sorry i use Pear Pagination class, you could also try it, saves you time formulating the pagination logic. it's easier and most likely bug free => http://pear.php.net/package/Pager/docs Pls ignore if i'm not of any help Thanks! ________________________________ From: Gab Teo <doneatlast1000@xxxxxxxxx> To: php-objects@xxxxxxxxxxxxxxx Sent: Thu, February 18, 2010 5:35:03 PM Subject: Pagenation Set up I have a problem with this search script as it return all the information in the database when I search for any term,I set the pagenation to a limit of 10, but I can't firgure out why the set limit is not working. Can any one with an eagle eyes spot the error please? Gab <?php if(!empty($_ GET[Submit] )) { include("databaseco nfig.php" ); $term=$_GET[ 'term']; if($term == "") { echo "<p>Please enter a search...</p> "; exit; } else { echo "Your Search Result<br>"; "<p>"; } } $pagenum = 1; {$pagenum=$_ POST[page] ;} $rowsperpage = 10; $offset=($pagenum- 1)*$rowsperpage; $numrows=$row[ numrows]; $maxPage=ceil( $numrows/ $rowsperpage) ; $sql=mysql_query( "select * from selling where product like '$trimmed%' or description like '$trimmed%' or price like '$trimmed%' or info like '$trimmed%' or contactseller like '$trimmed%' order by id DESC "); if (mysql_num_rows( $sql)==0) echo " No result"; else { while ($result=mysql_ fetch_array( $sql)) { $id=$result[ id]; $product=$result[ product]; $description= $result[descript ion]; echo "<a href=fullsearch. php?id=$id> ".$result[ product]. "</a><br> "; echo "$result[descriptio n]"; echo "<p>"; } $pageno=$pagenum+ 1; $prev=$pagenum- 1; $penultimate= $maxPage- 1; if($pagenum= =$maxPage and $maxPage>1) { echo "<center>"; echo "[ <a href=search. php?page= $prev>PREVIOUS PAGE</a> ]"; echo " "; echo "[ <a href=search. php?page= 1>FIRST PAGE</a> ]"; echo "</center>"; } elseif($pagenum< $maxPage and $pagenum==1) { echo "<center>"; echo "[ <a href=search. php?page= $pageno>NEXT PAGE</a>]"; echo " "; echo "[ <a href=search. php?page= $maxPage> LAST PAGE</a>]"; echo "</center>"; } elseif($pagenum< $maxPage and $pagenum>1) { echo "<center>"; echo "[ <a href=search. php?page= 1>FIRST PAGE</a> ]"; echo " "; echo "[ <a href=search. php?page= $pageno>NEXT PAGE</a> ]"; echo " "; echo "[ <a href=search. php?page= $prev>PREVIOUS PAGE</a> ]"; echo " "; echo "[ <a href=search. php?page= $maxPage> LAST PAGE</a> ]"; echo "</center>"; } else echo "<center>This is the only page</center> "; echo "<center>Showing page $pagenum of $maxPage</center> "; } ?> [Non-text portions of this message have been removed] [Non-text portions of this message have been removed]