Posts: 801
Name: Will Craig
Location: Cheltenham, Gloucestershire, UK
|
How do i get javascript to include a text/php file and then reinclude it every 20 seconds to look for changes and update the changes on the page without refreshing?
I wan't this php code to be reprocessed every 20 seconds to get any new messages....
PHP Code:
<?php
$sql = "SELECT * FROM `shoutbox` ORDER BY `time` DESC LIMIT 20";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$username = $row["username"];
$shout = $row["shout"];
$time = $row["time"];
$time = ago2($time);
$shout = wordwrap($shout,75,'');
$statsid = mysql_query("SELECT `statsid` FROM `users_data`
WHERE `username` = '$username'");
$statsid = mysql_fetch_array($statsid);
$statsid = $statsid['statsid'];
print ("<tr height='10'>");
print ("<td align=left valign=top>$time</td>");
print ("<td align=left valign=top><a href='http://www.soldierextreme.com/stats.php?id=$statsid'><b>$username</b></a></td>");
print ("<td align=left><kbd>$shout</kbd></td>");
print ("</tr>");
}
?>
|