I have a code that does not work after PHP update, can someone help me update? I an not a programmer, and used a lot of time to make this code the first time. I have tried to change coding according to new standards SQLi, but I cannot get it to work.
The code below is the original.
{
var data1 = google.visualization.arrayToDataTable(
[
['date','Outdoor'],
<?php
// select average readings select * from readings where year(date) = 2015
$result = mysql_query("SELECT DATE_FORMAT( date , '%d.%c.%y %H:%i') AS Time1, AVG( out_temp ) AS out_temp FROM $table WHERE TIMESTAMPDIFF(HOUR,date, now()) < $hours GROUP BY ROUND( UNIX_TIMESTAMP( date ) DIV ($avg*3600) ) ");
if ($result !== false)
{
$num=mysql_numrows($result);
$i=0;
while ($i < $num)
{
$time=mysql_result($result,$i,"Time1");
$out_temp=mysql_result($result,$i,"out_temp");
echo "['";
echo "$time";
echo "',";
echo "$out_temp";
echo "]";
if ($i < ($num - 1)){
echo ",";
}
$i++;
}
}
?>
]);
var options1 =
{
title: 'Temperatures',
curveType: 'function',
legend: {position: 'bottom'},
animation:{duration: 1000,easing: 'in',startup: true},
vAxis: {viewWindowMode:'explicit',viewWindow: {max:35,min:-10} }
};
var chartA = new google.visualization.LineChart(document.getElementById('chart_div'));
chartA.draw(data1, o
ptions1);