I want to rerun a php function on a timer so it runs every x ammount of time then when it runs again i want to update the page with the new value without reloading (useing ajax i think)
function get_usedram($arg) {
if ($arg == kb) {
$totalram = get_totalram(kb);
$freeram = get_freeram(kb);
$sum = $totalram - $freeram;
return $sum . ' ' . 'KB';
}
else if ($arg == mb) {
$totalram = get_totalram(mb);
$freeram = get_freeram(mb);
$sum = $totalram - $freeram;
return $sum . ' ' . 'MB';
}
else if ($arg == gb) {
$totalram = get_totalram(gb);
$freeram = get_freeram(gb);
$sum = $totalram - $freeram;
return $sum . ' ' . 'GB';
}
}
This is my function it pulls in two other function to get the ammount of RAm being used by the server i want to run this every 5 seconds for example then update the value i have on screen im useing it like this:
echo get_usedram(gb) . ' ' . 'Ram Being Used';
Thanks!