LukeFosterZ
Member
- Dec 22, 2016
- 89
- 11
Wondering if anyone has the files or a custom online counter for client
Many thanks
Many thanks
<?php
$connection = new mysqli("db_host", "db_user", "db_password", "db_name");
$sql = "SELECT COUNT(*) FROM users WHERE online='1'";
$result = $connection->query($sql);
echo $result;
$connection->close();
<script>
const fetchInterval = 30000 // Time between each fetch query 30000/1000 = 30 seconds.
let getOnline = () => {
fetch('/online').then(res => {
document.querySelector("#online-element").innerHTML(res);
})
}
setInterval(getOnline, fetchInterval);
</script>
online-element
, where it will output the current online amount. You can rip it off someone else's client page or design your own, I won't spoonfeed you that much.