Jump to content

Pagination!!!


rameshfaj

Recommended Posts

I have some entries in the database.The item includes itemid,itemname,description,itempicture etc...Now I wanted to display the items on pages.The page should have previous link,next link and the link to page numbers as well.I know this is a simple pagination problem as done in many sites but I need to have some codes or scripts if possible.

Any sorts of help is appreciated a lot!

Link to comment
Share on other sites

What I do is execute the query, then use the mysql_num_rows function to get the total results...I then start at 0 then increment by 50 until I hit the total....

 

If(!$_POST['start']){

$start=0;

}Else{

$start=$_POST['start']+50;

}

 

$select = mysql_query("SELECT * FROM table WHERE field='test' LIMIT $start, 50") or die(mysql_error());

 

$totalRows=mysql_num_rows($select);

 

while($sql=mysql_fetch_array($select)) {

 

 

}

 

You just then need to create a simple form for each previous and next which has a hidden value called start and then submit the form to itself, for previous you just subtract 50, there is some fault tolerence you need to put into place as well like, if it is less than 0 or greater than $totalRows....like I said this will get you started but it is not complete code...

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.