sungpeng Posted April 21, 2009 Share Posted April 21, 2009 $selectquery = "SELECT * FROM listings where rid=$_GET[rid]"; $result = mysql_query($selectquery) or die ("Query failed"); while ($row = mysql_fetch_array($result)) { echo "$row[description]"; } Check my $row[description] will give me 200 results, can I display it from page 1 to page 10 instead of all in one page. Quote Link to comment https://forums.phpfreaks.com/topic/154971-solved-display-200-results-from-page-1-to-page-10/ Share on other sites More sharing options...
SWD Posted April 21, 2009 Share Posted April 21, 2009 Hey sungpeng, Use the LIMIT keyword in your SQL. The syntax is basically LIMIT <START RECORD>, <NUM RECORDS TO RETURN> So therefore for the first 10 records you would have SELECT .... FROM ... WHERE.... LIMIT 0,10 For the 60-70 records you would have SELECT .... FROM ... WHERE.... LIMIT 60,10 Be careful with "one-off" overlaps... .but that should do the trick. Good luck LP Quote Link to comment https://forums.phpfreaks.com/topic/154971-solved-display-200-results-from-page-1-to-page-10/#findComment-815151 Share on other sites More sharing options...
sungpeng Posted April 21, 2009 Author Share Posted April 21, 2009 ok but sometime I have 25 results only then I need it to display 3 pages only instead of 10 pages that is preset and viewers can click next to go to next pages. It is common but I need some advise on coding it. Quote Link to comment https://forums.phpfreaks.com/topic/154971-solved-display-200-results-from-page-1-to-page-10/#findComment-815153 Share on other sites More sharing options...
.josh Posted April 21, 2009 Share Posted April 21, 2009 what you want is called pagination. http://www.phpfreaks.com/tutorial/basic-pagination Quote Link to comment https://forums.phpfreaks.com/topic/154971-solved-display-200-results-from-page-1-to-page-10/#findComment-815154 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.