Jump to content

php help ?


jd2007

Recommended Posts

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

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

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.