eugene2009 Posted October 27, 2009 Share Posted October 27, 2009 What is the easiest way to make the results display 10 per page? May anybody please help? Here is the code: $commentquery = mysql_query("SELECT * FROM comments WHERE tutorialid='$tutid' ORDER BY date DESC") or die(mysql_error()); $commentNum = mysql_num_rows($commentquery); echo "<table width=\"540\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#25b7c1\"bordercolor=\"#25bc1\"><tr><td><div id=\"currentcomments\" class=\"submitcomment\"><br><h2 class=\"formtitle\">Current Comments</center></h2>\n"; echo "<p align=\"left\"><B><u>" . $commentNum . "</u></b> comments so far (<a href=\"#post\">post your own</a>)</p>"; while($commentrow = mysql_fetch_row($commentquery)){ $commentbb = BBCode($commentrow[4]); $commentDate = formatDate($commentrow[6]); echo "<div class=\"commentbody\" id=\"$commentrow[0]\">\n <p class=\"postedby\" align=\"left\">Posted by <B><u>"; if($commentrow[3]){ echo "<a href=\"$commentrow[3]\">$commentrow[2]</a> "; } else { echo "$commentrow[2] "; } echo "</b></u>on $commentDate </p>\n <p align=\"left\">$commentbb</p>\n \n</div>"; } echo "</div></td></tr></table>"; } function submitComments($tutid2,$tuturl){ Quote Link to comment https://forums.phpfreaks.com/topic/179232-solved-paging-results-10-per-page/ Share on other sites More sharing options...
kickstart Posted October 27, 2009 Share Posted October 27, 2009 Hi Keep track of the page number and then either use LIMIT in the SQL to only bring back the records for 1 page, or use mysql_data_seek() to jump to the first record and drop out of the while loop once you have displayed X records. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/179232-solved-paging-results-10-per-page/#findComment-945625 Share on other sites More sharing options...
eugene2009 Posted October 27, 2009 Author Share Posted October 27, 2009 im sorry, but im a little new to mysql may you please give me an example? Quote Link to comment https://forums.phpfreaks.com/topic/179232-solved-paging-results-10-per-page/#findComment-945636 Share on other sites More sharing options...
Maq Posted October 27, 2009 Share Posted October 27, 2009 im sorry, but im a little new to mysql may you please give me an example? There is a good tutorial here on phpfreaks: http://www.phpfreaks.com/tutorial/basic-pagination Quote Link to comment https://forums.phpfreaks.com/topic/179232-solved-paging-results-10-per-page/#findComment-945645 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.