Code :
<?php
$db=mysqli_connect("mysql17.000webhost.com","username","pwd","db");
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysql_connect_error();
}
$result = mysqli_query($db,"SELECT * FROM ChatBox");
Print "<div style='text-align:center;'>";
Print "<table border cellpadding=3 style='text-align:left;width:auto;left:auto;right:auto;display:inline-block;'>";
while($info = mysqli_fetch_array( $result ))
{
Print "<tr>";
Print "<th>User : </th> <td>".$info['User'] . " </td>";
Print "<th>Content : </th> <td>".$info['Content'] . " </td></tr>";
}
Print "</table></div>";
Using this code, it will print it in the order of the time of the content added, which I want is to print it in the order of opposite of the time of the content added.
e.g.
before adding content
db:
User | Content
ABC | Hello1
DEF | Hello2
after adding content
User | Content
ABC | Hello1
DEF | Hello2
GHI | Hello3
using this code it will print
User : ABC
Content : Hello1
User : EFG
Content : Hello2
User : GHI
Content : Hello3
and what is expected to be printed after adding content to sql database :
User : GHI
Content : Hello3
User : EFG
Content : Hello2
User : ABC
Content : Hello1