Freid001 Posted December 20, 2010 Share Posted December 20, 2010 Ok so I have a PHP code below. How can I use Ajax to refresh this code every 5 seconds with out a page refresh? Any help would be great! Thanks -------------------------------------------------------------------------------------------- <?php $host= XXXX $mysql_user = XXXX $mysql_password = XXXX $mysql_database = XXXX ;$username = $test; $connection = XXXX $query = mysql_query("SELECT * FROM Game WHERE user='$username'"); $numrows = mysql_num_rows($query); while ($row = mysql_fetch_assoc($query)) { $Comment = $row['Comment']; } echo "$Comment"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/222213-ajax-refresh-code-every-5-seconds/ Share on other sites More sharing options...
Adam Posted December 22, 2010 Share Posted December 22, 2010 You can use the setInterval() method to periodically call your AJAX function. What have you tried so far? Quote Link to comment https://forums.phpfreaks.com/topic/222213-ajax-refresh-code-every-5-seconds/#findComment-1150235 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.