ILYAS415 Posted August 8, 2008 Share Posted August 8, 2008 Hi. Im making a game and im tyring to update a players health automatically every 10 seconds. Heres what I have come up with... <script language="javascript" type="text/javascript"> <!-- function updateHealth(){ changeText("health", "<b>H</b>ealth: [<?= $fetch->health ?>/<?= $fetch->maxhealth ?>]"); } setInterval("updateHealth()", 10000); //every 10 seconds //--> </script> The above code works fine. However if i were to change the players health on the db, it wouldnt change on the page every 10 seconds. It would get the original rows from when the page originally loaded. Help please? Thanks Link to comment https://forums.phpfreaks.com/topic/118852-updating-a-string-on-the-same-page-every-x-seconds/ Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 1) Don't use short tags. 2) Look into Ajax. Link to comment https://forums.phpfreaks.com/topic/118852-updating-a-string-on-the-same-page-every-x-seconds/#findComment-612046 Share on other sites More sharing options...
ILYAS415 Posted August 8, 2008 Author Share Posted August 8, 2008 Lol sorry i missed out the fact that i didnt want to use Ajax. Its too much to go just to edit something so small. Btw i already no how to use ajax Link to comment https://forums.phpfreaks.com/topic/118852-updating-a-string-on-the-same-page-every-x-seconds/#findComment-612050 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.