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 ? Link to comment https://forums.phpfreaks.com/topic/59588-php-help/ 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> | "; } } Link to comment https://forums.phpfreaks.com/topic/59588-php-help/#findComment-296079 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 Link to comment https://forums.phpfreaks.com/topic/59588-php-help/#findComment-296080 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.