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
https://forums.phpfreaks.com/topic/48300-pagination/
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
https://forums.phpfreaks.com/topic/48300-pagination/#findComment-236123
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.