title: Load MySql table from bottom to top - PHP
body: <p>Today is my first day ever messing with PHP or MySQL... I tried to make a simple chat program... it works great but it displays the old chats first and the newest chats (which are at the bottom of my table) last (at the bottom of the page).. how can I load the table in reverse order? So it displays the rows front he bottom of the database table at the top of my HTML table?</p>
  
  <p>Here is my code... All in the file called "Chat.php"</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;
  &lt;form action="chat.php" method="post"&gt;
  Message: &lt;br&gt;&lt;textarea type="text" name="message" style="width:80%; height:300px;"&gt;&lt;/textarea&gt;&lt;br&gt;
  &lt;input type="submit" /&gt;
  &lt;/form&gt;
  
  &lt;?php
  
  $host="****";
  $user="****";
  $password="****";
  
  $cxn = mysql_pconnect ($host, $user, $password);
  
  mysql_select_db("defaultdb", $cxn);
  
  if (getenv(HTTP_X_FORWARDED_FOR)) {
      $ipaddress = getenv(HTTP_X_FORWARDED_FOR);
  } else {
      $ipaddress = getenv(REMOTE_ADDR);
  }
  
  $message = $_POST["message"];
  
  mysql_query("INSERT INTO ChatTest (ID, TimeStamp, Message) VALUES ('$ipaddress', NOW(), '$message')");
  
  $data = mysql_query("SELECT * FROM ChatTest") or die(mysql_error()); 
   Print "&lt;table border cellpadding=3&gt;"; 
   Print "&lt;tr&gt;"; 
   Print "&lt;th&gt;ID:&lt;/th&gt;&lt;th&gt;TimeStamp:&lt;/th&gt;&lt;th&gt;Message:&lt;/th&gt;";
   while($info = mysql_fetch_array( $data )) { 
   Print "&lt;tr&gt;"; 
      Print " &lt;td&gt;".$info['ID'] . "&lt;/td&gt; "; 
      Print " &lt;td&gt;".$info['TimeStamp'] . " &lt;/td&gt;";
      Print " &lt;td&gt;".$info['Message'] . "&lt;/td&gt;&lt;/tr&gt;"; 
   } 
   Print "&lt;/table&gt;"; 
  
  mysql_close($cxn);
  
  
  ?&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>