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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.