Код: Выделить всё
<?php
$db = mysql_connect ("localhost","user","pas"); mysql_select_db ("radius",$db);
$result = mysql_query("SELECT * FROM radcheck");
while ($myr = mysql_fetch_array($result)){
$resin= mysql_query("SELECT SUM(acctoutputoctets) FROM radacct WHERE username = '".$myr['username']."'",$db);
$myrin = mysql_fetch_array($resin);
$sumtrafu = $myr['trafinmb'];
if (isset($sumtrafu)) {
$datain1 = $myrin[0]; $datain1 = $datain1 / 1024 / 1024; $sumtrafin = round($datain1,0);
if($sumtrafin > $sumtrafu) {$res = mysql_query ("UPDATE radreply SET value='off' WHERE username='".$myr['username']."'",$db);}
}
}
?>