Hi, I am new to PHP.
I am trying to make a system on a website where users can post updates (very simple).
I have a MySQL database which has a table containing username, subject, date, content.
Based on this it creates a table:
<?php
$myCon = new mysqli("localhost", "root");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$myCon->select_db("PAS");
$query = "SELECT * FROM homedata";
$result = mysqli_query($myCon,$query);
while($row = mysqli_fetch_array($result))
{
echo "<table width=394 height=90 border=0><tr>";
echo "<td width=384 height=21 background=\"lightbg.jpg\" bgcolor=\"#CCCCCC\"><span class=\"style10\">";
echo $row['topic'];
echo "</span> </td></tr><tr><td valign=\"top\" background=\"bgtext.jpg\"><span class=\"style7\">";
echo $row['info'];
echo "<p class=\"style11\">";
echo "Posted by ";
echo $row['user'];
echo " on ";
echo $row['date'];
echo "</span></td></table>";
}
?>
What this does however is output the oldest entries first (since they are added first)
I want to read in the database in reverse sequential order... how should I do this? Otherwise how can I insert entries so that the newest entry is appended to the top of the table? (Note: I don't know which would be more efficient since I have no Idea how SQL stores data behind the scenes)