Hey! I made this kind of comments thing with php and mySQL but I have a problem. The problem is, the very post comment someone made is at the top! And the lastest is at the bottom :bemused: I know why, but how do I fix it? I remember remotely something about ORDER but I'm not sure:
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName"); $sqlquery = "select * from $table ";
$result = mysql_query($sqlquery);
$number = mysql_numrows($result);
$i = 0;
if ($number < 1) {
$worked = "false";
} else {
while($row = mysql_fetch_array( $result )) {
echo "<table width='300' border='0' cellspacing='0' cellpadding='0'>";
echo "<tr>";
echo "<td height='15'><span class='main_bold'>".$row['title']." </span><span class='main2'>by ".$row['poster']."</span> </td>";
echo "</tr><tr>";
echo "<td height='78' valign='top' class='main'><p>";
echo $row['comment'];
echo "</p>
<p><em>- Posted on ".$row['time']." </em></p></td>";
echo "</tr>";
echo "</table>";
}
}
The code is probably very sloppy, but it works 🙂
The structure of the table is: id - poster - time - title - comment --- if it helps 🙂
the time wont help you, because it is Friday the 08th of July 2005 at 04:43:33 PM in format.
The ID is auto increment so the first post is 1, or actually 4 in this case, and the 5, 6, etc