add a number in while loop
Posted
by Luke
on Stack Overflow
See other posts from Stack Overflow
or by Luke
Published on 2010-05-15T14:58:53Z
Indexed on
2010/05/15
15:04 UTC
Read the original article
Hit count: 253
php
if ($num_rows > 0)
{
while($row=mysql_fetch_assoc($res))
{
$fromuser=$row['username'];
$comment=$row['comment'];
$commentdate=$row['date'];
$date=strtotime($commentdate);
$final_date=date("g:i a", $date);
$final_date2=date("F j Y", $date);
?>
<table align="center" width="100%"style='border-top: 1px dotted;'bgcolor="#eeeeee" >
<tr><td><?echo "<a href=\"userprofile.php?user=$fromuser\"><b>$fromuser</b></a> commented:\n";?></td></tr>
<tr><td><?echo "at $final_date on $final_date2\n";?></td></tr>
<tr bgcolor="#ffffff"><td><?echo "$comment\n";?></td></tr>
</table><br>
<?
}
}
else
{
echo"There are currently no comments on this user";
}
?>
I am looking for a way to add a number to each comment. So 1, 2, 3, 4, etc in DESC order. I can't think how I can do this?
© Stack Overflow or respective owner