I have comments in a mysql table each with a number (rank). I would like my site to have these comments on the page sorted by highest number. In other words, all the comments should appear but in descending order based on their rank (an int). Under each comment I would also like to generate a textarea to add new comments. I’m thinking this should all go in one table. I get stuck generating the table because the number of rows is variable depending on how many posts return.
This is what I have so far:
<?php
include 'connect.php';
$get=mysql_query("SELECT * FROM table WHERE $x='comments'");
$numberofrows=mysql_num_rows($get);
while ($row=mysql_fetch_assoc($get)){
$comment=$row['comment'];
$rank=$row['rank'];
echo "<table>";
echo "</table>";
}
?>
To get the order use
ORDER BYin your SQL:You should put the
<table>elements outside the loop