I have a php page which finds the active events from mysql and loops through the result and then print the details. It find the event name, event start time and total joined users, but the page's data only refreshes when the user reopen the page, what i want is only for the joined users column to update after some interval.
$result=fetchEventList();
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<div class=\"row\">
<div class=\"td td1\">".$row["EventName"]."</div>
<div class=\"td td2\">".$row["StartTime"]."</div>
<div class=\"td td3\">".$row["JoinedUsers"]."</div>";
}
}
I searched and found many answers using javascript and loading only a div, but its not working for me, i tried
<script type = \"text/javascript\">
setInterval(\"my_function();\", 5000);
function my_function(){
$('.td3').load(location.href + ' #time');
}
But its not working, can anyone nudge me in the direction to follow, also i dont' want to refresh the whole page again, just the joined users div for all the events
setInterval( my_function, 5000);, setInterval will call the function after the timer is done.