how to display new comment at the top/first on page?
I used a code before but it,s not work when I add reply system in my comment box.
My used code is:
$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++;}
This is my current comment structure with above code which not work as last comment first also display total comment system continuously again after again for above code:
$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>'; }
?>