MySQL code help
Posted: Sat 07 Apr 2018 3:30 pm
I have virtually no knowledge about MySQL but with considerable help here in the past I had been able to create some scripts from my MySQL Dayfile DB
Monthly temp http://www.komokaweather.com/mysql/monthly-temp.php
Monthly data http://www.komokaweather.com/mysql/monthly-data.php
Today to previous http://www.komokaweather.com/weather/maxmin.php
This date http://www.komokaweather.com/weather/thisdate.php
I have been trying to create a new script that would have a table of each day's temp for the 10 years of my data -
Year as column header (11 columns from 2008 to 2018)
Each day's date in the left column (365 lines or 366 in leap year) possibly beak it down in monthly blocks
Each day's high temp filled in the table
I would then do the same for low temp and average temp.
Unfortunately my attempts at deciphering and editing the MySQL code from those working scrips has not given me any results for my new script idea
I have this code in my This Date script
And in my Maxin
Any code suggestion for obtaining the temp for each day and year?
Thanks,
Paul
Monthly temp http://www.komokaweather.com/mysql/monthly-temp.php
Monthly data http://www.komokaweather.com/mysql/monthly-data.php
Today to previous http://www.komokaweather.com/weather/maxmin.php
This date http://www.komokaweather.com/weather/thisdate.php
I have been trying to create a new script that would have a table of each day's temp for the 10 years of my data -
Year as column header (11 columns from 2008 to 2018)
Each day's date in the left column (365 lines or 366 in leap year) possibly beak it down in monthly blocks
Each day's high temp filled in the table
I would then do the same for low temp and average temp.
Unfortunately my attempts at deciphering and editing the MySQL code from those working scrips has not given me any results for my new script idea
I have this code in my This Date script
Code: Select all
// the actual query for the grid data the query displays date for
$q1 = "SELECT year(LogDate) as year, month(LogDate) as month, day(LogDate) as day, LogDate, MinTemp, LowAppTemp, LowWindChill, MaxTemp, HighAppTemp, round(AvgTemp,1) as AvgTemp, MinPress, MaxPress, HighWindGust, TotWindRun, round(TotRainFall,1) as TotRainFall, round(HoursSun,1) as HoursSun FROM Dayfile WHERE day(LogDate)=day(now()) and month(LogDate)=month(now()) ORDER BY year(LogDate) DESC";
$result1 = mysql_query($q1)or die('Error: ' . mysql_error());
Code: Select all
// the actual query for the grid data
$SQL = "SELECT LogDate, Year(LogDate) as Year, maxtemp, max(IF(month(logdate)=1, maxtemp,null)) as January, max(IF(month(logdate)=2, maxtemp,null))as February, max(IF(month(logdate)=3, maxtemp,null))as March, max(IF(month(logdate)=4, maxtemp,null))as April, max(IF(month(logdate)=5, maxtemp,null))as May, max(IF(month(logdate)=6, maxtemp,null))as June, max(IF(month(logdate)=7, maxtemp,null))as July, max(IF(month(logdate)=8, maxtemp,null))as August ,max(IF(month(logdate)=9, maxtemp,null))as September,max(IF(month(logdate)=10, maxtemp,null))as October, max(IF(month(logdate)=11, maxtemp,null))as November, max(IF(month(logdate)=12, maxtemp,null))as December, max(maxtemp) as total FROM Dayfile group by year";
$resultmaxtemp = mysql_query($SQL)or die('Error: ' . mysql_error());
Thanks,
Paul