jd2007 Posted July 12, 2007 Share Posted July 12, 2007 i created a php script which takes user's comment and insert it into a mysql database, then display the comments from the database. what i want now is, if there is more than six comments printed on a page, i want php to automatically create a new page for me, and display the seventh comment in that new page...pls help me...how do i do that ? Quote Link to comment Share on other sites More sharing options...
abdfahim Posted July 12, 2007 Share Posted July 12, 2007 You can try this if(isset($_GET['pag'])){ $pag=$_GET['pag']; }else{ $pag=0; } $list=mysql_query("SELECT * FROM comment_table ORDER BY ID"); $row=mysql_num_rows(list); $total=ceil($row/6); for ($j=0;$j<6;$j++){ $i=($pag*6+$j); if($i==$row){break;} $comm=mysql_result($list,$i,"comment"); echo $comm."<br>"; } //For displaying next page links if numbeer of page is greater than 1 if($total>1){ $count=0; while($count<$tp_total){ if($count!=$pag){echo "<a href=\"comment.php?page=$count\">";} $count++; echo "Page $count</a> | "; } } Quote Link to comment Share on other sites More sharing options...
JayBachatero Posted July 12, 2007 Share Posted July 12, 2007 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.