我有一个网站,人们可以在上面发布他们的推特网址,人们可以从那里关注他们。url 发布是由 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>" ;
}
?>