PHP Code:
<?php
//Connect to MySQL
mysql_connect('localhost','root','') or exit;
//Select database
mysql_select_db('chat') or exit;
$result = mysql_query("select * from chat order by time desc limit 10");
while($row = mysql_fetch_array($result)){
echo '<div class="message"><div class="messagehead">' . $row['name'] . ' - '
. date('g:i A M, d Y',$row['time']) . '</div><div class="messagecontent">' . $row['message'] . '</div></div>';
}
$old = time() - (24 * 60 * 60); // The 24 is in last 24 hours, set it to what you want
mysql_query('delete from chat where time < '.$old.'');
?>

Leave a comment: