PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $b = $b -1; date_default_timezone_set('America/New_York'); $localtime_assoc = localtime(time(), true); $cc = $localtime_assoc['tm_hour']; $hh=$cc; $vv = $cc; if ($b > $vv) { $y=$b-$vv; $chop = mysql_query("DELETE FROM allnetworks ORDER BY id DESC LIMIT $y"); } if ($b >= 24) { $f =mysql_query ("DELETE FROM allnetworks"); $uniquenetwork = mysql_query("SELECT DISTINCT network FROM ststats WHERE network !=''"); $x=1; while ($row = mysql_fetch_assoc($uniquenetwork)) { $network = $row['network']; $total = mysql_query("SELECT AVG(vote) AS resultsavg FROM ststats WHERE network='$network'"); $row = mysql_fetch_assoc($total); $total2 = $row["resultsavg"]; $roundedaverage = round($total2); if ($x==1) { $addtocolumns = mysql_query("INSERT INTO allnetworks ($network) VALUES ($roundedaverage)"); $id=mysql_insert_id(); $x++; } else { $addtootherscolumns = mysql_query("UPDATE allnetworks SET $network = $roundedaverage WHERE id = $id"); } } } else if ($b<$vv) { echo "added". "<br>"; $z=$vv-$b; for ($i = 0; $i < $z; $i++) { $uniquenetwork = mysql_query("SELECT DISTINCT network FROM ststats WHERE network !=''"); $x=1; while ($row = mysql_fetch_assoc($uniquenetwork)) { $network = $row['network']; $total = mysql_query("SELECT AVG(vote) AS resultsavg FROM ststats WHERE network='$network'"); $row = mysql_fetch_assoc($total); $total2 = $row["resultsavg"]; $roundedaverage = round($total2); if ($x==1) { $addtocolumns = mysql_query("INSERT INTO allnetworks ($network) VALUES ($roundedaverage)"); $id=mysql_insert_id(); $x++; } else { $addtootherscolumns = mysql_query("UPDATE allnetworks SET $network = $roundedaverage WHERE id = $id"); } } } } ?>
Show:  
Copy Clear