如何在每10次删除顶部的注释

时间:2012-08-11 02:29:31

标签: php html comments

我有一个网站,人们发布他们的推特网址,人们可以从那里关注他们。网址发布是由php发布脚本处理我的问题是,我可以删除20条评论后的第一条评论,这样他们就不会永远继续下去吗?我希望它像这个网站一样工作http://tumblrplug.com/注意:我将评论存储在mysql数据库中,并附有每个评论的计数器。

评论的代码是:

<?php
require('connect.php');
$query=mysql_query("SELECT * FROM comment ORDER BY id DESC");
while($rows=mysql_fetch_assoc($query))
{
     $id=$rows['id'];
     $dname=$rows['name'];
     $dcomment=$rows['comment'];

     echo '<font  id = "username_word" color="red">username:</font>' ."<a href='$dname' id = 'name' style='color: #77cde6' STYLE='TEXT-DECORATION: NONE'>$dname</a>"."<font class='dash' color='red'> - </font> "."<div id='comment'>$dcomment</div>" 
  ."<a href='$dname'><img src='http://i45.tinypic.com/2yltzkg.png' width ='30px' height ='30px' border='0' alt='follow' id='followbtn'></a>" ;    

     }
?>

查询代码就是这样:

<?php
require('connect.php');
$query=mysql_query("SELECT * FROM comment ORDER BY id DESC");
while($rows=mysql_fetch_assoc($query))
{
     $id=$rows['id'];
     $dname=$rows['name'];
     $dcomment=$rows['comment'];

     echo '<font  id = "username_word" color="red">username:</font>' ."<a href='$dname' id = 'name' style='color: #77cde6' STYLE='TEXT-DECORATION: NONE'>$dname</a>"."<font class='dash' color='red'> - </font> "."<div id='comment'>$dcomment</div>" 
  ."<a href='$dname'><img src='http://i45.tinypic.com/2yltzkg.png' width ='30px' height ='30px' border='0' alt='follow' id='followbtn'></a>" ;    

     }
?>

1 个答案:

答案 0 :(得分:1)

每次从评论表加载时是否重新查询?如果是这样,您可以将返回的行数限制为20。

SELECT * FROM comment ORDER BY id DESC LIMIT 20