Jump to content

[SOLVED] Paging Results 10 per page


eugene2009

Recommended Posts

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){

Link to comment
https://forums.phpfreaks.com/topic/179232-solved-paging-results-10-per-page/
Share on other sites

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

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.