gpt4 book ai didi

php - 如何在页面顶部/首页显示新评论

转载 作者:行者123 更新时间:2023-11-29 23:44:44 24 4
gpt4 key购买 nike

如何在页面顶部/第一个显示新评论?

我之前使用过代码,但是当我在评论框中添加回复系统时,它不起作用。

我使用的代码是:

$count = mysql_numrows($results);
$i = 0;
while ($i < $count){

$qazi_id = mysql_result($results,$i,"qazi_id");
$username = mysql_result($results,$i,"username");
$email = mysql_result($results,$i,"email");
$description = mysql_result($results,$i,"description");
$url = mysql_result($results,$i,"url");
$date = mysql_result($results,$i,"date");

other code

$i++;}

这是我当前的评论结构,上面的代码不能作为最后一条评论首先使用,并且对于上面的代码再次连续显示总评论系统:

 $results = mysql_query("SELECT * FROM comments WHERE qazi_id='$tutid' ORDER BY id DESC") or die(mysql_error());

$commentNum = mysql_num_rows($results);

echo' <div class="post-bottom-section">
<h2> '.$commentNum.' comments so far (<a href="#post" title="post your own">post your own</a>)</h2>
<div class="primary">
<ol class="commentlist">';

$count = mysql_numrows($results);
$i = 0;
while ($i < $count){

$qazi_id = mysql_result($results,$i,"qazi_id");
$username = mysql_result($results,$i,"username");
$email = mysql_result($results,$i,"email");
$description = mysql_result($results,$i,"description");
$url = mysql_result($results,$i,"url");
$date = mysql_result($results,$i,"date");

//heres our alternating hack
if($css != "depth-1"){ $css = "depth-1"; }else{ $css = "thread-alt depth-1"; }

$q = "SELECT * FROM comments WHERE parent_id = 0";
$r = mysql_query($q);
while($row = mysql_fetch_assoc($r)) // Only main comment
{ $id = $row['id'];
$qazi_id = $row['qazi_id'];
$username = $row['username'];
$email = $row['email'];
$description = $row['description'];
$url = $row['url'];
$parent_id = $row['parent_id'];
$date = $row['date'];
echo'
<div class="comment-info">
<img alt="" class="avatar" height="42" width="42" src="'.$grav_url.'"/>
<cite>
<a href="'.$url.'" title="'.$username.'">'.$username.'</a> Says: <br />
<span class="comment-data"><a href="'.$url.'" title="'.$date.'">'.$date.'</a></span>
</cite>
</div>
<div class="comment-text">
<p>'.BBCode($description).'</p>
</div>
<a href="#post" class="reply" id="'.$id.'">Reply</a>
';
$query = "SELECT * FROM comments WHERE parent_id ='$id'";
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res)) // Only main comment
{ $id = $row['id'];
$qazi_id = $row['qazi_id'];
$username = $row['username'];
$email = $row['email'];
$description = $row['description'];
$url = $row['url'];
$parent_id = $row['parent_id'];
$date = $row['date'];
echo' <ul><li>
<div class="comment-info">
<img alt="" class="avatar" height="42" width="42" src="'.$grav_url.'"/>
<cite>
<a href="'.$url.'" title="'.$username.'">'.$username.'</a> Says: <br />
<span class="comment-data"><a href="'.$url.'" title="'.$date.'">'.$date.'</a></span>
</cite></div>
<div class="comment-text">
<p>'.BBCode($description).'</p>
</div>
</li></ul>';
}}
$i++;
}echo'</ol></div></div>'; }
?>

最佳答案

将查询更改为SELECT * FROM comments WHERE Parent_id = 0 ORDER BY id DESC

关于php - 如何在页面顶部/首页显示新评论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26001010/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com