Hey, I've added this:https://imgur.com/a/px4jl https://i.imgur.com/VskcDZy.png http://prntscr.com/hf9sy8into my client and it doesn't auto reload when another user comes online
Can someone help?
Printable View
Hey, I've added this:https://imgur.com/a/px4jl https://i.imgur.com/VskcDZy.png http://prntscr.com/hf9sy8into my client and it doesn't auto reload when another user comes online
Can someone help?
You can achieve this by either using websockets or an AJAX request and an interval.
create a php file with the name onlinecount.php, and put the code in it
Change what's inside <?php in the first line, to that of your cmsCode:<?phprequire_once('./data_classes/server-data.php_data_classes-core.php.php');require_once('./data_classes/server-data.php_data_classes-session.php.php');$maintenance2 = mysql_num_rows(mysql_query("SELECT * FROM cms_settings WHERE mantenimiento = '1'"));$useradmin2 = mysql_query("SELECT * FROM users WHERE username = '" . $_SESSION['username'] . "'");$useradmin = mysql_fetch_array($useradmin2);$palavrasbloqueadas=file_get_contents('./Files/PalavrasBloqueadas.txt');if($maintenance2 == '1' && $useradmin['rank'] < 5){ header("Location: manutencao");}?><html><head></head><body><div class="clientOnlineBox"><div class="clientOnlineBoxTxt" id="onlinecount"><small><b><?php echo $UsersOnline; ?></b> Online!</small></div><img src="http://200.98.70.115/Externos/img/onlineiconclient.png" style="width:29px;height:28px;ht; */position: absolute;margin-left: 130px;margin-top: -19px;"></div></div></body></html>
Then use this div in your client.php
5000 = 5 secondsCode:<script type="text/javascript"> setInterval("$('#onlinecount').load('onlinecount.php');", 5000);</script>
<div id="onlinecount"><?phpinclude ("onlinecount.php");?></div>
I've done the first part but you put "Change what's inside <?php in the first line, to that of your cms" what do you mean by that lol?
Assuming you have a php file online_count.php that spits out the amount of users online
Jquery & Ajax
Code:$(document).ready(function(){
setInterval(function(){
$.ajax({
url:'/online_count.php',
dataType:'json',
success:function(response){
// Update the online counter value with the response data
}
});
},5000);
});