Page 1 of 1

Help with PHP paging...

Posted: Thu Sep 09, 2004 5:12 pm
by suz_1234
Hello,

This is a new post and has nothing to do with the bottom replies... I am trying to do Paging and need some help...

I got this code online, but I dont remember what site it was from...

Here's what part of the code looks like:

Code: Select all

PHP: Pager.php

   function nextPrev($curpage, $pages) 
    { 
     $next_prev  = ""; 

     if (($curpage-1) <= 0) 
      &#123; 
       $next_prev .= "Previous"; 
      &#125; 
     else 
      &#123; 
       $next_prev .= "<a href="".$_SERVER&#1111;'PHP_SELF']."?page=".($curpage-1)."">Previous</a>"; 
      &#125; 

     $next_prev .= " | "; 

     if (($curpage+1) > $pages) 
      &#123; 
       $next_prev .= "Next"; 
      &#125; 
     else 
      &#123; 
       $next_prev .= "<a href="".$_SERVER&#1111;'PHP_SELF']."?page=".($curpage+1)."">Next</a>"; 
      &#125; 

     return $next_prev; 
    &#125;

Code: Select all

PHP: listBooks.php

$next_prev = $p->nextPrev($_GET&#1111;'page'], $pages);
		  echo $next_prev;
There are 15 items in my table and I want to print 6 items each page... The above code prints all 15 items in First Page and show me with Previous |Next .. and Next links to listBooks.php with the same 15 items in the First Page...

Any ideas y it does that???

Thanks for all your help..

Posted: Thu Sep 09, 2004 5:29 pm
by feyd

Code: Select all

SELECT * FROM searchAisle
is likely the problem...

adding 'or die(mysql_error())' to your query call would help.

and please use

Code: Select all

tags when posting php code.

Posted: Thu Sep 09, 2004 6:36 pm
by suz_1234
Thank you so much,
That worked.. I am glad people like you take time to help immature programmer like me :)