Help with PHP paging...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
suz_1234
Forum Newbie
Posts: 24
Joined: Sat Sep 04, 2004 11:22 pm

Help with PHP paging...

Post 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..
Last edited by suz_1234 on Fri Sep 10, 2004 3:21 am, edited 2 times in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
suz_1234
Forum Newbie
Posts: 24
Joined: Sat Sep 04, 2004 11:22 pm

Post by suz_1234 »

Thank you so much,
That worked.. I am glad people like you take time to help immature programmer like me :)
Post Reply