Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » PHP




 Page 1 of 1 [ 4 posts ] 



Author Message
 Post subject: Pagin Results ten for a page
 Post Posted: Thu Nov 12, 2009 11:13 am 
Offline

Joined: Sat Feb 21, 2009 2:24 pm
Posts: 30
What was da easiest way 2 make da results display 10 per page? May
anybody please help?

Here is the code:
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){


Top 
 Post subject: Re: Pagin Results ten for a page
 Post Posted: Thu Nov 12, 2009 11:14 am 
Offline

Joined: Sat Feb 21, 2009 1:08 pm
Posts: 549
Hi

Keep track of da page number nd then either use LIMIT in da SQL 2 only bring
back da records 4 1 page, r do the use mysql_data_seek() 2 jump 2 da first record and drop out of the while loop once you have displayed X records.

All da best


Top 
 Post subject: Re: Pagin Results ten for a page
 Post Posted: Thu Nov 12, 2009 11:14 am 
Offline

Joined: Sat Feb 21, 2009 2:24 pm
Posts: 30
I m sorry, but I n little new 2 mysql
could u pls take da pain of givn me an exmple!!!:-)


Top 
 Post subject: Re: Pagin Results ten for a page
 Post Posted: Thu Nov 12, 2009 11:15 am 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
There is a good tutorial
http://www.phpfreaks.com/tutorial/basic-pagination


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 4 posts ] 




Board index » Server Side Development » PHP


Who is online

Users browsing this forum: No registered users and 2 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron