rameshfaj Posted April 23, 2007 Share Posted April 23, 2007 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! Quote Link to comment Share on other sites More sharing options...
mpharo Posted April 23, 2007 Share Posted April 23, 2007 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... Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 23, 2007 Share Posted April 23, 2007 There are a couple of tutorials on that on this site: http://www.phpfreaks.com/tutorial_cat/25/Page-Number--Pagination.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.