Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Top 10 Records Page

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderators: daj, TNETWeather

User avatar
MackerelSky
Posts: 138
Joined: Fri Apr 01, 2011 8:14 pm
Weather Station: Davis VP2 w/FARS
Operating System: Toshiba Laptop Windows 7 x64
Location: Smethport, Pa.
Contact:

Re: Top 10 Records Page

Postby MackerelSky » Sat Nov 22, 2014 12:23 pm

bobhutton wrote:Sorry, it was not my intention to hijack this this thread.
Bob

Yeah, that was my reason for posting what I did. I had no way of knowing if your server was working correctly without being able to see any errors, like I would be able to do if you had your site on the web.

Your errors are simple enough to correct.

Warning: include(./page_header_inc.php) blah blah line 57

This just means when you downloaded the script you didn't download Mark's 'header file' for his site and that line in the code is useless to you and php can't find the file. That's where you would put the path to your own header file once you create one.

Open up the script, go to line 57 and either remove that line or put two slashes in front of it. '//"

// include(./page_header_inc.php)

Do that for all of the errors mentioned, save it and give it another try.

Brad
Davis VP2/FARS
Cumulus 1.9.4(1092)

McKean Weather
'cause not everyone lives at the airport

Image

bobhutton
Posts: 12
Joined: Mon Apr 07, 2014 7:30 am
Weather Station: Fine Offset
Operating System: Windows 7
Location: Notts, UK

Re: Top 10 Records Page

Postby bobhutton » Sat Nov 22, 2014 1:00 pm

top10s.php was in htdocs, not a sub directory.

Editing the script has done the trick. It is all cleaned up after deleting the lines. the insertion of // left the error messages in and showed the // after the error messages.

Thanks all for your patience.

Bob

User avatar
MackerelSky
Posts: 138
Joined: Fri Apr 01, 2011 8:14 pm
Weather Station: Davis VP2 w/FARS
Operating System: Toshiba Laptop Windows 7 x64
Location: Smethport, Pa.
Contact:

Re: Top 10 Records Page

Postby MackerelSky » Sat Nov 22, 2014 2:07 pm

Good News... :clap:

Have fun with your journey.

Brad
Davis VP2/FARS
Cumulus 1.9.4(1092)

McKean Weather
'cause not everyone lives at the airport

Image

User avatar
studebaker
Posts: 89
Joined: Mon Feb 14, 2011 6:27 pm
Weather Station: National Geographic 265NC
Operating System: Windows 10
Location: Kemptville, On, Canada
Contact:

Re: Top 10 Records Page

Postby studebaker » Sun Mar 08, 2015 10:03 pm

Could someone help me get my top ten up and running? I have been struggling with it for several days and can't seem to get beyond the following error despite countless hours of research combined with trial and error attempts. Don`t like to give up, but my head hurts!
I realize that once this error is corrected, others may develop but at least that`s progress ;)

Fatal error: Call to undefined function mysqli() in /var/sites/k/kerrentweather.ca/public_html/topten.php on line 274

Here is my topten php:

<?php
//----------------------------------------------------------------------
// Top 10's from a MySql database
// Author: Mark Crossley
//
// Ver 0.1 - 22/10/13 - Initial release, 0.X = a work in progress, breakages and changes on the fly likely!
// Ver 0.2 - 23/10/13 - Applied min-width:135px to all the main table <td>'s
// Ver 0.3 - 23/10/13 - Made the SQL table name a variable
// Ver 0.4 - 23/10/13 - Added IS NOT NULL to simpleHiLo query
// Ver 0.5 - 24/10/13 - Added wettest years (can also do driest)
// Ver 0.6 - 24/10/13 - Changed rain day threshold to cater for in/mm
// Ver 0.7 - 01/12/13 - Restructured to add category header rows
// - Added greatest/smallest temp & humidity ranges, heat/coolDegDays, smallest pressure range
// - Added execution times
// Ver 0.8 - 03/12/13 - Fixed MaxSolarRad
// Ver 0.9 - 04/12/13 - Added min MaxSolarRad (dull days)
// Ver 0.10 02/01/14 - Added highlighting of recent records
// Ver 0.11 12/01/14 - Fixed missing blank data cells in output
// Ver 0.12 07/02/14 - Added 'most/least rain days in a month', removed 'Driest Years'
// Ver 0.13 12/03/14 - Fixed a logic problem in the row/cell layout code
// Ver 0.14 10/11/14 - Added Frost days: Earliest, Latest, Most, Least
// Ver 0.15 02/02/15 - Ordered equal records by date ascending (oldest first)
//----------------------------------------------------------------------
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------

// Standard Source view option check
function check_sourceview () {
if (isset($_GET['view']) && ($_GET['view'] == 'sce' || $_GET['view'] == 'src')) {
$filenameReal = __FILE__;
$download_size = filesize($filenameReal);
header('Pragma: public');
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header("Content-type: text/plain");
header("Accept-Ranges: bytes");
header("Content-Length: $download_size");
header('Connection: close');
readfile($filenameReal);
exit;
}
}

// Just list the PHP source?
check_sourceview();

//include 'page_header_inc.php';

$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;

$unitT = '&deg;C';
$unitR = 'mm';
$unitRR = 'mm/h';
$unitW = 'mph';
$unitWR = 'miles';
$unitP = 'hPa';
// default rain day thresholds = 0.2mm or 0.01" - you may want to over-ride these values
$rainDayThreshold = ($unitR === 'mm' ? 0.2 : 0.01);

$dayFileTableName = 'dayfile';

$cells = 5; // number of data tables to row on the page
$recentHighlight = 32; // number of days (+1) of recent records to highlight

// Hidden MySQL read-only connection parameters
//include '../forbidden/db_ro_details.php';


// Create the page header - with embedded CSS to avoid a separate file (frowned on by some!)
?>
<style>
.cell1 {
text-align: right;
width: 40%;
}
table {
padding: 0px;
width: 100%;
}
table td {
font-size: 0.9em;
}
caption {
text-align: center;
border-bottom: #000;
border-bottom-width: thin;
border-bottom-style: solid;
}
.dataTable td {
padding-right: 4px;
padding-left: 4px;
vertical-align: bottom;
border-top: 0 !important;
background: transparent !important;
}
.header {
text-align: center;
font-size: 1.2em;
font-weight: bold;
border-bottom: #000;
border-bottom-width: thin;
border-bottom-style: solid;
border-top: #000;
border-top-width: thin;
border-top-style: solid;
color: #2EC0FF;
}
.cTempH {
background: #ffdddd; /* Old browsers */
background: -moz-linear-gradient(top, #ffdddd 14%, #c6c6ff 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(14%,#ffdddd), color-stop(100%,#c6c6ff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffdddd 14%,#c6c6ff 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffdddd 14%,#c6c6ff 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffdddd 14%,#c6c6ff 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffdddd 14%,#c6c6ff 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffdddd', endColorstr='#c6c6ff',GradientType=0 ); /* IE6-9 */
}
.cTempL {
background: #c6c6ff; /* Old browsers */
background: -moz-linear-gradient(top, #c6c6ff 0%, #ffdddd 86%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c6c6ff), color-stop(86%,#ffdddd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #c6c6ff 0%,#ffdddd 86%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #c6c6ff 0%,#ffdddd 86%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #c6c6ff 0%,#ffdddd 86%); /* IE10+ */
background: linear-gradient(to bottom, #c6c6ff 0%,#ffdddd 86%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c6c6ff', endColorstr='#ffdddd',GradientType=0 ); /* IE6-9 */
}
.cWindH {
background: #d2fdc7; /* Old browsers */
background: -moz-linear-gradient(top, #d2fdc7 0%, #f7f7f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d2fdc7), color-stop(100%,#f7f7f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #d2fdc7 0%,#f7f7f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #d2fdc7 0%,#f7f7f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #d2fdc7 0%,#f7f7f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #d2fdc7 0%,#f7f7f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d2fdc7', endColorstr='#f7f7f7',GradientType=0 ); /* IE6-9 */
}
.cWindL {
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #d2fdc7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#d2fdc7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#d2fdc7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#d2fdc7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#d2fdc7 100%); /* IE10+ */
background: linear-gradient(to bottom, #f7f7f7 0%,#d2fdc7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#d2fdc7',GradientType=0 ); /* IE6-9 */
}
.cPressH {
background: #afffeb; /* Old browsers */
background: -moz-linear-gradient(top, #afffeb 0%, #f7f7f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#afffeb), color-stop(100%,#f7f7f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #afffeb 0%,#f7f7f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #afffeb 0%,#f7f7f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #afffeb 0%,#f7f7f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #afffeb 0%,#f7f7f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#afffeb', endColorstr='#f7f7f7',GradientType=0 ); /* IE6-9 */
}
.cPressL {
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #afffeb 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#afffeb)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#afffeb 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#afffeb 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#afffeb 100%); /* IE10+ */
background: linear-gradient(to bottom, #f7f7f7 0%,#afffeb 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#afffeb',GradientType=0 ); /* IE6-9 */
}
.cHumH {
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #e0e0e0 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#e0e0e0)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#e0e0e0 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#e0e0e0 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#e0e0e0 100%); /* IE10+ */
background: linear-gradient(to bottom, #f7f7f7 0%,#e0e0e0 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#e0e0e0',GradientType=0 ); /* IE6-9 */
}
.cHumL {
background: #e0e0e0; /* Old browsers */
background: -moz-linear-gradient(top, #e0e0e0 0%, #f7f7f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e0e0e0), color-stop(100%,#f7f7f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #e0e0e0 0%,#f7f7f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #e0e0e0 0%,#f7f7f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #e0e0e0 0%,#f7f7f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #e0e0e0 0%,#f7f7f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e0e0e0', endColorstr='#f7f7f7',GradientType=0 ); /* IE6-9 */
}
.cSolarH {
background: #ffffb2; /* Old browsers */
background: -moz-linear-gradient(top, #ffffb2 0%, #f7f7f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffb2), color-stop(100%,#f7f7f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffb2 0%,#f7f7f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffb2 0%,#f7f7f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffb2 0%,#f7f7f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffffb2 0%,#f7f7f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffb2', endColorstr='#f7f7f7',GradientType=0 ); /* IE6-9 */
}
.cSolarL {
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #ffffb2 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#ffffb2)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#ffffb2 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#ffffb2 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#ffffb2 100%); /* IE10+ */
background: linear-gradient(to bottom, #f7f7f7 0%,#ffffb2 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#ffffb2',GradientType=0 ); /* IE6-9 */
}
.cRainH {
background: #d6edfa; /* Old browsers */
background: -moz-linear-gradient(top, #d6edfa 0%, #f7f7f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d6edfa), color-stop(100%,#f7f7f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #d6edfa 0%,#f7f7f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #d6edfa 0%,#f7f7f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #d6edfa 0%,#f7f7f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #d6edfa 0%,#f7f7f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d6edfa', endColorstr='#f7f7f7',GradientType=0 ); /* IE6-9 */
}
.cRainL {
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #d6edfa 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#d6edfa)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#d6edfa 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#d6edfa 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#d6edfa 100%); /* IE10+ */
background: linear-gradient(to bottom, #f7f7f7 0%,#d6edfa 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#d6edfa',GradientType=0 ); /* IE6-9 */
}
.cDewL {
background: #eeccff; /* Old browsers */
background: -moz-linear-gradient(top, #eeccff 0%, #ffccaf 99%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeccff), color-stop(99%,#ffccaf)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #eeccff 0%,#ffccaf 99%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #eeccff 0%,#ffccaf 99%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #eeccff 0%,#ffccaf 99%); /* IE10+ */
background: linear-gradient(to bottom, #eeccff 0%,#ffccaf 99%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeccff', endColorstr='#ffccaf',GradientType=0 ); /* IE6-9 */
}
.cDewH {
background: #ffccaf; /* Old browsers */
background: -moz-linear-gradient(top, #ffccaf 1%, #eeccff 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#ffccaf), color-stop(100%,#eeccff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffccaf 1%,#eeccff 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffccaf 1%,#eeccff 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffccaf 1%,#eeccff 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffccaf 1%,#eeccff 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffccaf', endColorstr='#eeccff',GradientType=0 ); /* IE6-9 */
}
.cTempH, .cTempL, .cWind, .cPress, .cHum, .cSolar, .cRainH, .cRainL, .cDewL, .cDewH {
width: 20%;
min-width: 135px;
}
.recent {
color: blue;
}
</style>
</head>
<body>
<?php
// Connect to the database
$mysqli = mysqli($kerrentw_topten, $kerrentw_topten, $temporary, $kerrentw_topten);
if ($mysqli->connect_errno) {
die('Failed to connect to the database server - ' . $mysqli->connect_error);
}

// $dataArrays holds the query data, and the returned values
// initially only populate it with simple high/low type queries
$dataArrays =
array( // 0-displayOrder, 1-fieldName, 2-caption, 3-highVals?, 4-decimalPlaces, 5-CSSclass, 6-(returned values - append post SQL queries)
array(0,"Temperature Records ($unitT)",'cTempL'),
array(1,'MinTemp','Min Temp',false,1,'cTempL'),
array(2,'AvgTemp','Min Avg Temp',false,1,'cTempL'),
array(3,'MaxTemp','Lowest Max Temp',false,1,'cTempL'),
array(4,'MaxTemp - MinTemp','Smallest Daily Temp Range',false,1,'cTempL'),
array(5,'HeatDegDays','Max Heating Deg Days',true,1,'cTempL'),
array(6,'MaxTemp','Max Temp',true,1,'cTempH'),
array(7,'AvgTemp','Max Avg Temp',true,1,'cTempH'),
array(8,'MinTemp','Highest Min Temp',true,1,'cTempH'),
array(9,'MaxTemp - MinTemp', 'Greatest Daily Temp Range', true, 1, 'cTempH'),
array(10,'CoolDegDays','Max Cooling Deg Days',true,1,'cTempH'),

array(100,"Derived Temperature Records ($unitT)",'cDewH'),
array(101,'LowAppTemp','Min Apparent Temp',false,1,'cDewL'),
array(102,'HighAppTemp','Max Apparent Temp',true,1,'cDewH'),
array(103,'LowDewPoint','Min Dew Point',false,1,'cDewL'),
array(104,'HighDewPoint','Max Dew Point',true,1,'cDewH'),
array(105,'LowWindChill','Min Wind Chill',false,1,'cDewL'),

array(200,'Humidity Records (RH%)','cHumL'),
array(201,'LowHum','Min Humidity',false,0,'cHumL'),
array(202,'HighHum - LowHum', 'Greatest Daily Humidity Range', true, 1, 'cHumH'),
array(203,'HighHum - LowHum', 'Smallest Daily Humidity Range', false, 1, 'cHumL'),

array(300,"Wind Records ($unitW)",'cWind'),
array(301,'HighAvgWSpeed','Max Avg Wind Spd',true,0,'cWindH'),
//array(302,'HighAvgWSpeed','Lowest Max Avg Wind',false,0,'cWindL'),
array(303,'HighWindGust','Max Wind Gust Spd',true,0,'cWindH'),
array(304,'HighWindGust','Lowest Max Wind Gust',false,0,'cWindL'),
array(305,'TotWindRun',"Max Daily Wind Run ($unitWR)",true,1,'cWindH'),
array(306,'TotWindRun',"Min Daily Wind Run ($unitWR)",false,1,'cWindL'),

array(400,"Pressure Records ($unitP)",'cPress'),
array(401,'MinPress','Min Pressure',false,1,'cPressL'),
array(402,'MaxPress','Max Pressure',true,1,'cPressH'),
array(403,'MaxPress - MinPress','Smallest Daily Press Change',false,1,'cPressL'),
array(404,'MaxPress - MinPress','Greatest Daily Press Change',true,1,'cPressH'),

array(500,"Rain Records ($unitR)",'cRainH'),
array(501,'MaxRainRate',"Max Rain Rate ($unitRR)",true,1,'cRainH'),
array(502,'HighHourRain','Max Rain in 1hr',true,1,'cRainH'),
array(503,'TotRainFall','Max Daily rain',true,1,'cRainH'),

array(600,'Solar Records (since 21 April 2013)','cSolarH'),
array(601,'HighUV','Max UV Index',true,1,'cSolarH'),
array(602,'HoursSun','Max Sunshine hours',true,1,'cSolarH'),
// array(603,'CAST(HighSolarRad AS UNSIGNED)','Max Solar Radiation Wm&#8315;&sup2;',true,0,'cSolarH'), // need to fix dayfile table, using varchar!
array(603,'HighSolarRad','Max Solar Radiation Wm&#8315;&sup2;',true,0,'cSolarH'), // table fixed!
array(605,'TotalEvap',"Max Evapotranspiration ($unitR)",true,1,'cSolarH')
);
// start of SQL execution timer
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$startSQLtime = $mtime;

// Step though $dataArray and fetch the simple high/low data from MySQL
$len = count($dataArrays);
for ($x = 0; $x < $len; $x++) {
// do not process the 100's entry's, they are headers!
if ($dataArrays[$x][0] % 100 > 0) {
$vals = simpleHiLo($dataArrays[$x][1], $dataArrays[$x][3], $dataArrays[$x][4], $recentHighlight);
// store returned values in the array
$dataArrays[$x][6] = $vals;
}
}

//#### Now we add the 'non-standard' query data #####

//Driest months
$vals = wetDryMonthsYears(true, 1, true);
$dataArrays[] = array(504,'DryMonths', 'Driest Months', false, 1, 'cRainL', $vals);

//Wettest months
$vals = wetDryMonthsYears(false, 1, true);
$dataArrays[] = array(505,'WetMonths', 'Wettest Months', false, 1, 'cRainH', $vals);

//Driest years
//$vals = wetDryMonthsYears(true, ($unitR === 'mm' ? 0 : 1), false);
//$dataArrays[] = array(506,'WetYears', 'Driest Years', false, 1, 'cRainL', $vals);

//Wettest years
$vals = wetDryMonthsYears(false, ($unitR === 'mm' ? 0 : 1), false);
$dataArrays[] = array(507,'WetYears', 'Wettest Years', false, 1, 'cRainH', $vals);

//Longest runs of dry days
$vals = consecutiveDryWetDays('D', $recentHighlight);
$dataArrays[] = array(508,'DryDays', 'Consecutive Dry Days (end date)', false, 1, 'cRainL', $vals);

//Longest runs of wet days
$vals = consecutiveDryWetDays('W', $recentHighlight);
$dataArrays[] = array(509,'WetDays', 'Consecutive Wet Days (end date)', false, 1, 'cRainH', $vals);

//Most dry days in a month
$vals = rainDaysMonth(true);
$dataArrays[] = array(510,'DryCount', 'Most Dry Days in a Month', false, 0, 'cRainL', $vals);

//Most rain days in a month
$vals = rainDaysMonth(false);
$dataArrays[] = array(511,'WetCount', 'Most Rain Days in a Month', false, 0, 'cRainH', $vals);

//Dullest days
$vals = minMaxSolarRad($recentHighlight);
$dataArrays[] = array(604,'LowSolarRad','Lowest Max Solar Radiation Wm&#8315;&sup2;',true, 0, 'cSolarL', $vals);

//Frost days
$vals = minMaxFrostDays(true);
$dataArrays[] = array(11,'MinFrost','First Frost Day',false,0,'cTempL',$vals);
$vals = minMaxFrostDays(false);
$dataArrays[] = array(12,'MaxFrost','Last Frost Day',true,0,'cTempH',$vals);
$vals = cntFrostDays(false);
$dataArrays[] = array(13,'HiFrostCnt','Most Frost Days',true,0,'cTempL',$vals);
$vals = cntFrostDays(true);
$dataArrays[] = array(14,'LoFrostCnt','Least Frost Days',false,0,'cTempH',$vals);


//End of SQL execution timer
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totalSQLtime = ($endtime - $startSQLtime);

//sort the array for display
function cmp_by_firstSubElement($a, $b) {
return $a[0] - $b[0];
}
usort($dataArrays, "cmp_by_firstSubElement");

//### All done, end of the data queries
//###########################################################################################
// Some standard functions to perform the MySQL queries

// Get the 10 highest/lowest values for the supplied field
function simpleHiLo($fld, $hi, $dec, $rcnt) {
global $dayFileTableName, $mysqli;
$query = 'SELECT LogDate, ' .
"ROUND($fld, $dec), " .
"Logdate >= DATE_SUB(CURDATE(), INTERVAL $rcnt DAY) " .
"FROM $dayFileTableName " .
"WHERE $fld IS NOT NULL " .
"ORDER BY $fld " . ($hi ? 'DESC' : 'ASC') . ', LogDate ASC ' .
'LIMIT 10';
$result = $mysqli->query($query);
if (!$result) {
die('ERROR - Bad Select Statement (1) - ' . $mysqli->error);
}
// import the rows and put the data into an array
while ($row = $result->fetch_array()) {
$rtn[] = $row;
}
return $rtn;
}

// Get the 10 longest dry/wet spells, $dryWet = "D" or "W"
function consecutiveDryWetDays($dryWet, $rcnt) {
global $dayFileTableName, $rainDayThreshold, $mysqli;
$query = 'SELECT ' .
//'MIN(LogDate) AS date_from, ' .
'MAX(LogDate) AS date_to,' .
'COUNT(*) AS cnt, ' .
"MAX(Logdate) >= DATE_SUB(CURDATE(), INTERVAL $rcnt DAY) " .
'FROM ( ' .
'SELECT ' .
"@r := @r + (@rain != (TotRainFall >= $rainDayThreshold) OR @rain IS NULL) AS gr," .
"@rain := (TotRainFall >= $rainDayThreshold)," .
"IF (TotRainFall < $rainDayThreshold, 'D', 'W') AS wd," .
'df.LogDate ' .
'FROM (' .
'SELECT @r := 0,' .
'@rain := NULL' .
') vars,' .
"$dayFileTableName df ".
'ORDER BY LogDate' .
') x '.
"WHERE wd = '$dryWet' " .
'GROUP BY gr ' .
'ORDER BY cnt DESC, LogDate ASC ' .
'LIMIT 10';
$result = $mysqli->query($query);
if (!$result) {
die('ERROR - Bad Select Statement (2) - ' . $mysqli->error);
}
// import the rows and put the data into an array
while ($row = $result->fetch_array()) {
$rtn[] = $row;
}
return $rtn;
}

// Get the 10 wettest/driest months
function wetDryMonthsYears($dry, $dec, $mnth) {
global $dayFileTableName, $mysqli;
$query = "SELECT DATE_FORMAT(LogDate,'" . ($mnth ? '%b ' : '') . "%Y') AS intv, " .
"ROUND(SUM(TotRainFall), $dec) AS rain, " .
"DATE_FORMAT(LogDate,'" . ($mnth ? '%b ' : '') . "%Y') = DATE_FORMAT(CURDATE(),'" . ($mnth ? '%b ' : '') . "%Y')" .
"FROM $dayFileTableName " .
'GROUP BY intv ' .
'ORDER BY rain ' . ($dry ? 'ASC' : 'DESC') . ', LogDate ASC ' .
'LIMIT 10';
$result = $mysqli->query($query);
if (!$result) {
die('ERROR - Bad Select Statement (3) -' . $mysqli->error);
}
// import the rows and put the data into arrays
while ($row = $result->fetch_array()) {
$rtn[] = $row;
}
return $rtn;
}

// Get the 10 months with most/least rain days
function rainDaysMonth($dry) {
global $dayFileTableName, $mysqli;
$query = 'SELECT DATE_FORMAT(LogDate, "%b %Y") as intv, ' .
'COUNT(*) as days, ' .
'DATE_FORMAT(LogDate, "%b %Y") = DATE_FORMAT(CURDATE(), "%b %Y") ' .
"FROM $dayFileTableName " .
'WHERE TotRainFall ' . ($dry ? '= ' : '> ') . '0 ' .
'GROUP BY intv ' .
'ORDER BY days DESC, LogDate ASC ' .
'LIMIT 10';
$result = $mysqli->query($query);
if (!$result) {
die('ERROR - Bad Select Statement (4) -' . $mysqli->error);
}
// import the rows and put the data into arrays
while ($row = $result->fetch_array()) {
$rtn[] = $row;
}
return $rtn;
}

// Get the 10 dullest days
function minMaxSolarRad($rcnt) {
global $dayFileTableName, $mysqli;
$query = 'SELECT LogDate, ' .
'ROUND(HighSolarRad,0), ' .
"Logdate >= DATE_SUB(CURDATE(), INTERVAL $rcnt DAY) " .
"FROM $dayFileTableName " .
'WHERE HighSolarRad > 0 ' .
'ORDER BY HighSolarRad ASC, LogDate ASC ' .
'LIMIT 10';
$result = $mysqli->query($query);
if (!$result) {
die('ERROR - Bad Select Statement (5) -' . $mysqli->error);
}
// import the rows and put the data into arrays
while ($row = $result->fetch_array()) {
$rtn[] = $row;
}
return $rtn;
}

// Get the early/late Frost Days
function minMaxFrostDays($first) {
global $dayFileTableName, $mysqli;
$query = 'SELECT CONCAT(Y1,"/",RIGHT(CONCAT("0",Y1+1-2000),2)), '.
'DATE_FORMAT(D1, "%d %b"), '.
'Y1 = YEAR(CURDATE() - INTERVAL 7 MONTH) '.
'FROM ( '.
'SELECT '.
'YEAR(LogDate - INTERVAL 7 MONTH) AS Y1, '.
($first ? 'MIN(LogDate)' : 'MAX(logDate)').' AS D1 '.
"FROM $dayFileTableName D ".
'WHERE MinTemp <= 0 '.
// I don't have records for Winter 2009, they start 2010, so cannot
// determine the earliest frost for this period. Start @ period 2010/11
($first ? 'AND LogDate > "2010-07-01" ' : '').
'GROUP BY Y1 '.
') AS T '.
'ORDER BY DATE_FORMAT((D1 + INTERVAL 7 MONTH),"%m%d") '.($first ? 'ASC ' : 'DESC ').
'LIMIT 10';
$result = $mysqli->query($query);
if (!$result) {
die('ERROR - Bad Select Statement (6) -' . $mysqli->error);
}
// import the rows and put the data into arrays
while ($row = $result->fetch_array()) {
$rtn[] = $row;
}
return $rtn;
}

// Get the total Frost Days
function cntFrostDays($min) {
global $dayFileTableName, $mysqli;
$query = 'SELECT CONCAT(Y1,"/",RIGHT(CONCAT("0",Y1+1-2000),2)), '.
'D1, '.
'Y1 = YEAR(CURDATE() - INTERVAL 7 MONTH) '.
'FROM ( '.
'SELECT '.
'YEAR(LogDate - INTERVAL 7 MONTH) AS Y1, '.
'COUNT(*) AS D1 '.
"FROM $dayFileTableName D ".
'WHERE MinTemp <= 0 '.
'GROUP BY Y1 '.
') AS T '.
'ORDER BY D1 '.($min ? 'ASC ' : 'DESC ').
'LIMIT 10';
$result = $mysqli->query($query);
if (!$result) {
die('ERROR - Bad Select Statement (6) -' . $mysqli->error);
}
// import the rows and put the data into arrays
while ($row = $result->fetch_array()) {
$rtn[] = $row;
}
return $rtn;
}
// End of the server side script
//###########################################################################################
// Start to build the page for the client
?>
<!-- Header & Menu -->
<?php include 'content_header.php'; ?>

<div id="site_content">
<div class="container">
<!-- Banner -->
<?php include 'content_banner.php'; ?>
<!-- Content -->
<div class="row">
<div class="section -1u 10u">
<h1>Top 10 Records</h1>
<p class="not-mobile">This page shows some of the Top 10 highs and lows recorded by this weather station.
General records began on 13th January 2010, solar records on 21st April 2013.<br>
New records (within the last <?php echo ($recentHighlight-1) ?> days, current month, or current year) are highlighted in blue text.
The data is updated just after midnight each day.</p>
<table>
<tbody>
<?php
// Walk the data array X records at a time (5 sub-tables per row on the page)
$recs = count($dataArrays);
$currRec = 0; // current index into array
$currCell = 0; // current cell in row

while ($currRec < $recs) {
// is the current record a header?
if ($dataArrays[$currRec][0] % 100 === 0) {
// yes, so show a header row
if ($currCell > 0) {
// already in a data row, so pad it out with empty <td>s to fill the row
for ($x = $currCell; $x < $cells; $x++) {
// add any empty cells to pad the row
echo '<td>&nbsp;</td>';
}
// end the row
echo '</tr>';
}
// display the header
echo '<tr><td colspan=' . $cells . ' class="header ' . '">' . $dataArrays[$currRec][1] . '</td></tr>';
// start a new row
$currCell = 0;
} else {
// no it is a data record...
if ($currCell === 0) {
// first cell, so create a new row
echo '<tr>';
}
// create an embedded table to display it
echo '<td class="' . $dataArrays[$currRec][5] . '"><table class="dataTable"><caption>' . $dataArrays[$currRec][2] . '</caption><tbody>';
$num = count($dataArrays[$currRec][6]); // number of rows for this data table (may be less than 10)
for ($i = 0; $i < 10; $i++) {
// do we have any records left for this category?
if ($i < $num) {
// yep, so show them
//recent record?
$rcntClass = ($dataArrays[$currRec][6][$i][2] === '1' ? ' recent' : '');
echo ' <tr><td class="cell1' . $rcntClass . '">' . $dataArrays[$currRec][6][$i][1] . '</td><td class="cell2' . $rcntClass . '">' . $dataArrays[$currRec][6][$i][0] . '</td></tr>';
} else {
// nope, so display an empty pair of cells
echo ' <tr><td>&nbsp;</td><td>&nbsp;</td></tr>';
}
}
echo '</tbody></table></td>';
$currCell += 1;
if ($currCell === $cells) {
// we have filled a row
echo '</tr>';
// start a new one
$currCell = 0;
}
}
// next array record
$currRec += 1;
}
// Now just end the page structure
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php include 'content_footer.php'; ?>
</body>
</html>

User avatar
mcrossley
Posts: 5008
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Postby mcrossley » Sun Mar 08, 2015 10:59 pm

It sounds like you need to talk to your web hosting organisation. Your web server does not seem to support PHP mysqli, which is the successor to the now deprecated PHP MySQL interface. Ask them to get it implemented/enabled for you.

User avatar
studebaker
Posts: 89
Joined: Mon Feb 14, 2011 6:27 pm
Weather Station: National Geographic 265NC
Operating System: Windows 10
Location: Kemptville, On, Canada
Contact:

Re: Top 10 Records Page

Postby studebaker » Sun Mar 08, 2015 11:12 pm

Mark,
Thanks for the info. I have been discussing my problem with them, but the PHP mysqli support was not part of the discussion. I will pursue this further.

MeteoBisignano
Posts: 79
Joined: Mon Mar 09, 2015 10:45 am
Weather Station: wh3080
Operating System: windows
Location: Cosenza

Re: Top 10 Records Page

Postby MeteoBisignano » Mon Mar 09, 2015 11:06 am

Hello friends are several days but I feel gives me this error:
ERROR - Bad Select Statement (1) - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Given that use a station WH 3080 with solar sensors

User avatar
mcrossley
Posts: 5008
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Postby mcrossley » Mon Mar 09, 2015 12:13 pm

MeteoBisignano wrote:Hello friends are several days but I feel gives me this error:
ERROR - Bad Select Statement (1) - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Given that use a station WH 3080 with solar sensors

Change the line...

Code: Select all

die('ERROR - Bad Select Statement (1) - ' . $mysqli->error);

to...

Code: Select all

die('ERROR - Bad Select Statement (1) - <br>' . $query . '<br>'. $mysqli->error);


That will give you offending select statement, and you can try it in phpmyadmin.

MeteoBisignano
Posts: 79
Joined: Mon Mar 09, 2015 10:45 am
Weather Station: wh3080
Operating System: windows
Location: Cosenza

Re: Top 10 Records Page

Postby MeteoBisignano » Mon Mar 09, 2015 12:56 pm

I uploaded the files have been found on the forum new2_php but now comes a new error
I proceeded to enter also suggested change but now it gives me this error: ERROR - Bad Select Statement (1) -
SELECT LogDate, ROUND(MinTemp, 1), Logdate >= DATE_SUB(CURDATE(), INTERVAL 8 DAY) FROM ./dayfile.txt WHERE MinTemp IS NOT NULL ORDER BY MinTemp ASC LIMIT 10

mcrossley wrote:
MeteoBisignano wrote:Hello friends are several days but I feel gives me this error:
ERROR - Bad Select Statement (1) - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Given that use a station WH 3080 with solar sensors

Change the line...

Code: Select all

die('ERROR - Bad Select Statement (1) - ' . $mysqli->error);

to...

Code: Select all

die('ERROR - Bad Select Statement (1) - <br>' . $query . '<br>'. $mysqli->error);


That will give you offending select statement, and you can try it in phpmyadmin.

MeteoBisignano
Posts: 79
Joined: Mon Mar 09, 2015 10:45 am
Weather Station: wh3080
Operating System: windows
Location: Cosenza

Re: Top 10 Records Page

Postby MeteoBisignano » Mon Mar 09, 2015 12:57 pm

This is:

<?php
//----------------------------------------------------------------------
// Top 10's from a MySql database
// Author: Mark Crossley
//
// Ver 0.1 - 22/10/13 - Initial release, 0.X = a work in progress, breakages and changes on the fly likely!
// Ver 0.2 - 23/10/13 - Applied min-width:135px to all the main table <td>'s
// Ver 0.3 - 23/10/13 - Made the SQL table name a variable
// Ver 0.4 - 23/10/13 - Added IS NOT NULL to simpleHiLo query
// Ver 0.5 - 24/10/13 - Added wettest years (can also do driest)
// Ver 0.6 - 24/10/13 - Changed rain day threshold to cater for in/mm
// Ver 0.7 - 01/12/13 - Restructured to add category header rows
// - Added greatest/smallest temp & humidity ranges, heat/coolDegDays, smallest pressure range
// - Added execution times
// Ver 0.8 - 03/12/13 - Fixed MaxSolarRad
// Ver 0.9 - 04/12/13 - Added min MaxSolarRad (dull days)
// Ver 0.10 02/01/14 - Added highlighting of recent records
// Ver 0.11 12/01/14 - Fixed missing blank data cells in output
//----------------------------------------------------------------------
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;

$unitT = '&deg;C';
$unitR = 'mm';
$unitRR = 'mm/h';
$unitW = 'mph';
$unitWR = 'miles';
$unitP = 'hPa';
// default rain day thresholds = 0.2mm or 0.01" - you may want to over-ride these values
$rainDayThreshold = ($unitR === 'mm' ? 0.2 : 0.01);

$dayFileTableName = './dayfile.txt';

$cells = 5; // number of data tables to row on the page
$recentHighlight = 8; // number of days (+1) of recent records to highlight

// Hidden MySQL read-only connection parameters
include ('db_ro_details.php');

// allow viewing of generated source
if ( isset($_REQUEST['source']) && strtolower($_REQUEST['source']) == 'view' ) {
//--self downloader --
$filenameReal = __FILE__;
$download_size = filesize($filenameReal);
header('Pragma: public');
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: text/plain');
header('Accept-Ranges: bytes');
header('Content-Length: $download_size');
header('Connection: close');

readfile($filenameReal);
exit;
}

// Set some headers
header('Content-type: text/html; charset=utf-8;');
header('Cache-Control: access plus 1 hour, private');
header('Expires:' . gmdate('D,d M Y H:i:s', time() + 3600) . ' GMT');

// Create the page header - with embedded CSS to avoid a separate file (frowned on by some!)
?>
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Top 10's - Camberley Weather</title>
<link href="weatherstyle.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="favicon1.ico">
<style>
.cell1 {
text-align: right;
width: 33%;
}
table {
padding: 0px;
width: 100%;
}
caption {
text-align: center;
border-bottom: #000;
border-bottom-width: thin;
border-bottom-style: solid;
}
td {
padding-right: 4px;
padding-left: 4px;
vertical-align: bottom;
}
.header {
text-align: center;
font-size: 1.3em;
font-weight: bold;
border-bottom: #000;
border-bottom-width: thin;
border-bottom-style: solid;
border-top: #000;
border-top-width: thin;
border-top-style: solid;
}
.cTempH {
background: #ffdddd; /* Old browsers */
background: -moz-linear-gradient(top, #ffdddd 14%, #c6c6ff 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(14%,#ffdddd), color-stop(100%,#c6c6ff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffdddd 14%,#c6c6ff 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffdddd 14%,#c6c6ff 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffdddd 14%,#c6c6ff 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffdddd 14%,#c6c6ff 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffdddd', endColorstr='#c6c6ff',GradientType=0 ); /* IE6-9 */
}
.cTempL {
background: #c6c6ff; /* Old browsers */
background: -moz-linear-gradient(top, #c6c6ff 0%, #ffdddd 86%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c6c6ff), color-stop(86%,#ffdddd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #c6c6ff 0%,#ffdddd 86%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #c6c6ff 0%,#ffdddd 86%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #c6c6ff 0%,#ffdddd 86%); /* IE10+ */
background: linear-gradient(to bottom, #c6c6ff 0%,#ffdddd 86%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c6c6ff', endColorstr='#ffdddd',GradientType=0 ); /* IE6-9 */
}
.cWindH {
background: #d2fdc7; /* Old browsers */
background: -moz-linear-gradient(top, #d2fdc7 0%, #f7f7f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d2fdc7), color-stop(100%,#f7f7f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #d2fdc7 0%,#f7f7f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #d2fdc7 0%,#f7f7f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #d2fdc7 0%,#f7f7f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #d2fdc7 0%,#f7f7f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d2fdc7', endColorstr='#f7f7f7',GradientType=0 ); /* IE6-9 */
}
.cWindL {
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #d2fdc7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#d2fdc7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#d2fdc7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#d2fdc7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#d2fdc7 100%); /* IE10+ */
background: linear-gradient(to bottom, #f7f7f7 0%,#d2fdc7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#d2fdc7',GradientType=0 ); /* IE6-9 */
}
.cPressH {
background: #afffeb; /* Old browsers */
background: -moz-linear-gradient(top, #afffeb 0%, #f7f7f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#afffeb), color-stop(100%,#f7f7f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #afffeb 0%,#f7f7f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #afffeb 0%,#f7f7f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #afffeb 0%,#f7f7f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #afffeb 0%,#f7f7f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#afffeb', endColorstr='#f7f7f7',GradientType=0 ); /* IE6-9 */
}
.cPressL {
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #afffeb 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#afffeb)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#afffeb 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#afffeb 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#afffeb 100%); /* IE10+ */
background: linear-gradient(to bottom, #f7f7f7 0%,#afffeb 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#afffeb',GradientType=0 ); /* IE6-9 */
}
.cHumH {
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #e0e0e0 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#e0e0e0)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#e0e0e0 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#e0e0e0 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#e0e0e0 100%); /* IE10+ */
background: linear-gradient(to bottom, #f7f7f7 0%,#e0e0e0 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#e0e0e0',GradientType=0 ); /* IE6-9 */
}
.cHumL {
background: #e0e0e0; /* Old browsers */
background: -moz-linear-gradient(top, #e0e0e0 0%, #f7f7f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e0e0e0), color-stop(100%,#f7f7f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #e0e0e0 0%,#f7f7f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #e0e0e0 0%,#f7f7f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #e0e0e0 0%,#f7f7f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #e0e0e0 0%,#f7f7f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e0e0e0', endColorstr='#f7f7f7',GradientType=0 ); /* IE6-9 */
}
.cSolarH {
background: #ffffb2; /* Old browsers */
background: -moz-linear-gradient(top, #ffffb2 0%, #f7f7f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffb2), color-stop(100%,#f7f7f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffb2 0%,#f7f7f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffb2 0%,#f7f7f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffb2 0%,#f7f7f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffffb2 0%,#f7f7f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffb2', endColorstr='#f7f7f7',GradientType=0 ); /* IE6-9 */
}
.cSolarL {
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #ffffb2 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#ffffb2)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#ffffb2 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#ffffb2 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#ffffb2 100%); /* IE10+ */
background: linear-gradient(to bottom, #f7f7f7 0%,#ffffb2 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#ffffb2',GradientType=0 ); /* IE6-9 */
}
.cRainH {
background: #d6edfa; /* Old browsers */
background: -moz-linear-gradient(top, #d6edfa 0%, #f7f7f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d6edfa), color-stop(100%,#f7f7f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #d6edfa 0%,#f7f7f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #d6edfa 0%,#f7f7f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #d6edfa 0%,#f7f7f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #d6edfa 0%,#f7f7f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d6edfa', endColorstr='#f7f7f7',GradientType=0 ); /* IE6-9 */
}
.cRainL {
background: #f7f7f7; /* Old browsers */
background: -moz-linear-gradient(top, #f7f7f7 0%, #d6edfa 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#d6edfa)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f7f7 0%,#d6edfa 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f7f7 0%,#d6edfa 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f7f7 0%,#d6edfa 100%); /* IE10+ */
background: linear-gradient(to bottom, #f7f7f7 0%,#d6edfa 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#d6edfa',GradientType=0 ); /* IE6-9 */
}
.cDewL {
background: #eeccff; /* Old browsers */
background: -moz-linear-gradient(top, #eeccff 0%, #ffccaf 99%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeccff), color-stop(99%,#ffccaf)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #eeccff 0%,#ffccaf 99%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #eeccff 0%,#ffccaf 99%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #eeccff 0%,#ffccaf 99%); /* IE10+ */
background: linear-gradient(to bottom, #eeccff 0%,#ffccaf 99%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeccff', endColorstr='#ffccaf',GradientType=0 ); /* IE6-9 */
}
.cDewH {
background: #ffccaf; /* Old browsers */
background: -moz-linear-gradient(top, #ffccaf 1%, #eeccff 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#ffccaf), color-stop(100%,#eeccff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffccaf 1%,#eeccff 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffccaf 1%,#eeccff 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffccaf 1%,#eeccff 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffccaf 1%,#eeccff 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffccaf', endColorstr='#eeccff',GradientType=0 ); /* IE6-9 */
}
.cTempH, .cTempL, .cWind, .cPress, .cHum, .cSolar, .cRainH, .cRainL, .cDewL, .cDewH {
width: 20%;
min-width: 135px;
}
.recent {
color: blue;
}
</style>
</head>
<body>
<?php
// Connect to the database
$con = @mysql_connect($dbhost, $dbuser, $dbpassword);
if (!$con) {
die('Failed to connect to the database server - ' . mysql_error());
}
if (!mysql_select_db($database, $con)) {
die('Failed to connect to the database on the server - ' . mysql_error());
}

// $dataArrays holds the query data, and the returned values
// initially only populate it with simple high/low type queries
$dataArrays =
array( // 0-displayOrder, 1-fieldName, 2-caption, 3-highVals?, 4-decimalPlaces, 5-CSSclass, 6-(returned values - append post SQL queries)
array(0,"Temperature Records ($unitT)",'cTempL'),
array(1,'MinTemp','Min Temp',false,1,'cTempL'),
array(2,'AvgTemp','Min Avg Temp',false,1,'cTempL'),
array(3,'MaxTemp','Lowest Max Temp',false,1,'cTempL'),
array(4,'MaxTemp - MinTemp','Smallest Daily Temp Range',false,1,'cTempL'),
array(5,'HeatDegDays','Max Heating Deg Days',true,1,'cTempL'),
array(6,'MaxTemp','Max Temp',true,1,'cTempH'),
array(7,'AvgTemp','Max Avg Temp',true,1,'cTempH'),
array(8,'MinTemp','Highest Min Temp',true,1,'cTempH'),
array(9,'MaxTemp - MinTemp', 'Greatest Daily Temp Range', true, 1, 'cTempH'),
array(10,'CoolDegDays','Max Cooling Deg Days',true,1,'cTempH'),

array(100,"Derived Temperature Records ($unitT)",'cDewH'),
array(101,'LowAppTemp','Min Apparent Temp',false,1,'cDewL'),
array(102,'HighAppTemp','Max Apparent Temp',true,1,'cDewH'),
array(103,'LowDewPoint','Min Dew Point',false,1,'cDewL'),
array(104,'HighDewPoint','Max Dew Point',true,1,'cDewH'),
array(105,'LowWindChill','Min Wind Chill',false,1,'cDewL'),

array(200,'Humidity Records (RH%)','cHumL'),
array(201,'LowHum','Min Humidity',false,0,'cHumL'),
array(202,'HighHum - LowHum', 'Greatest Daily Humidity Range', true, 1, 'cHumH'),
array(203,'HighHum - LowHum', 'Smallest Daily Humidity Range', false, 1, 'cHumL'),

array(300,"Wind Records ($unitW)",'cWind'),
array(301,'HighAvgWSpeed','Max Avg Wind Spd',true,0,'cWindH'),
//array(302,'HighAvgWSpeed','Lowest Max Avg Wind',false,0,'cWindL'),
array(303,'HighWindGust','Max Wind Gust Spd',true,0,'cWindH'),
array(304,'HighWindGust','Lowest Max Wind Gust',false,0,'cWindL'),
array(305,'TotWindRun',"Max Daily Wind Run ($unitWR)",true,1,'cWindH'),
array(306,'TotWindRun',"Min Daily Wind Run ($unitWR)",false,1,'cWindL'),

array(400,"Pressure Records ($unitP)",'cPress'),
array(401,'MinPress','Min Pressure',false,1,'cPressL'),
array(402,'MaxPress','Max Pressure',true,1,'cPressH'),
array(403,'MaxPress - MinPress','Smallest Daily Press Change',false,1,'cPressL'),
array(404,'MaxPress - MinPress','Greatest Daily Press Change',true,1,'cPressH'),

array(500,"Rain Records ($unitR)",'cRainH'),
array(501,'MaxRainRate',"Max Rain Rate ($unitRR)",true,1,'cRainH'),
array(502,'HighHourRain','Max Rain in 1hr',true,1,'cRainH'),
array(503,'TotRainFall','Max Daily rain',true,1,'cRainH'),

array(600,'Solar Records (since 21 April 2013)','cSolarH'),
array(601,'HighUV','Max UV Index',true,1,'cSolarH'),
array(602,'HoursSun','Max Sunshine hours',true,1,'cSolarH'),
// array(603,'CAST(HighSolarRad AS UNSIGNED)','Max Solar Radiation W/m&sup2;',true,0,'cSolarH'), // need to fix dayfile table, using varchar!
array(603,'HighSolarRad','Max Solar Radiation W/m&sup2;<br>(Bright Days)',true,0,'cSolarH'), // table fixed!
array(605,'TotalEvap',"Max Evapotranspiration ($unitR)",true,1,'cSolarH')
);
// start of SQL execution timer
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$startSQLtime = $mtime;

// Step though $dataArray and fetch the simple high/low data from MySQL
$len = count($dataArrays);
for ($x = 0; $x < $len; $x++) {
// do not process the 100's entry's, they are headers!
if ($dataArrays[$x][0] % 100 > 0) {
$vals = simpleHiLo($dataArrays[$x][1], $dataArrays[$x][3], $dataArrays[$x][4], $recentHighlight);
// store returned values in the array
$dataArrays[$x][6] = $vals;
}
}

//#### Now we add the 'non-standard' query data #####

//Driest months
$vals = wetDryMonthsYears(true, 1, true);
$dataArrays[] = array(504,'DryMonths', 'Driest Months', false, 1, 'cRainL', $vals);

//Wettest months
$vals = wetDryMonthsYears(false, 1, true);
$dataArrays[] = array(505,'WetMonths', 'Wettest Months', false, 1, 'cRainH', $vals);

//Driest years
$vals = wetDryMonthsYears(true, ($unitR === 'mm' ? 0 : 1), false);
$dataArrays[] = array(506,'WetYears', 'Driest Years', false, 1, 'cRainL', $vals);

//Wettest years
$vals = wetDryMonthsYears(false, ($unitR === 'mm' ? 0 : 1), false);
$dataArrays[] = array(507,'WetYears', 'Wettest Years', false, 1, 'cRainH', $vals);

//Longest runs of dry days
$vals = consecutiveDryWetDays('D', $recentHighlight);
$dataArrays[] = array(508,'DryDays', 'Consecutive Dry Days (end date)', false, 1, 'cRainL', $vals);

//Longest runs of wet days
$vals = consecutiveDryWetDays('W', $recentHighlight);
$dataArrays[] = array(509,'WetDays', 'Consecutive Wet Days (end date)', false, 1, 'cRainH', $vals);

//Dullest days
$vals = minMaxSolarRad($recentHighlight);
$dataArrays[] = array(604,'LowSolarRad','Lowest Max Solar Radiation W/m&sup2;<br>(Dull Days)',true, 0, 'cSolarL', $vals);


//End of SQL execution timer
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totalSQLtime = ($endtime - $startSQLtime);

//sort the array for display
function cmp_by_firstSubElement($a, $b) {
return $a[0] - $b[0];
}
usort($dataArrays, "cmp_by_firstSubElement");


//### All done, end of the data queries
//###########################################################################################
// Some standard functions to perform the MySQL queries

// Get the 10 highest/lowest values for the supplied field
function simpleHiLo($fld, $hi, $dec, $rcnt) {
global $dayFileTableName;
$query = "SELECT LogDate, ROUND($fld, $dec), " .
"Logdate >= DATE_SUB(CURDATE(), INTERVAL $rcnt DAY) " .
"FROM $dayFileTableName " .
"WHERE $fld IS NOT NULL " .
"ORDER BY $fld " . ($hi ? 'DESC ' : 'ASC ') .
'LIMIT 10';
$result = mysql_query($query);
if (!$result) {
die('ERROR - Bad Select Statement (1) - <br>' . $query . '<br>'. $mysqli->error);
}
// import the rows and put the data into an array
while ($row = mysql_fetch_row($result)) {
$rtn[] = $row;
}
return $rtn;
}

// Get the 10 longest dry/wet spells, $dryWet = "D" or "W"
function consecutiveDryWetDays($dryWet, $rcnt) {
global $dayFileTableName, $rainDayThreshold;
$query = 'SELECT ' .
// 'MIN(LogDate) AS date_from, ' .
'MAX(LogDate) AS date_to,' .
'COUNT(*) AS cnt, ' .
"MAX(Logdate) >= DATE_SUB(CURDATE(), INTERVAL $rcnt DAY) " .
'FROM ( ' .
'SELECT ' .
"@r := @r + (@rain != (TotRainFall >= $rainDayThreshold) OR @rain IS NULL) AS gr," .
"@rain := (TotRainFall >= $rainDayThreshold)," .
"IF (TotRainFall < $rainDayThreshold, 'D', 'W') AS wd," .
'df.LogDate ' .
'FROM (' .
'SELECT @r := 0,' .
'@rain := NULL' .
') vars,' .
"$dayFileTableName df ".
'ORDER BY LogDate' .
') x '.
"WHERE wd = '$dryWet' " .
'GROUP BY gr ' .
'ORDER BY cnt DESC ' .
'LIMIT 10';
$result = mysql_query($query);
if (!$result) {
die('ERROR - Bad Select Statement (2) - <br>' . $query . '<br>'. $mysqli->error);
}
// import the rows and put the data into an array
while ($row = mysql_fetch_row($result)) {
$rtn[] = $row;
}
return $rtn;
}

// Get the 10 wettest/driest months
function wetDryMonthsYears($dry, $dec, $mnth) {
global $dayFileTableName;
$query = "SELECT DATE_FORMAT(LogDate,'" . ($mnth ? '%b ' : '') . "%Y') AS intv, " .
"ROUND(SUM(TotRainFall), $dec) AS rain, " .
"DATE_FORMAT(LogDate,'" . ($mnth ? '%b ' : '') . "%Y') = DATE_FORMAT(CURDATE(),'" . ($mnth ? '%b ' : '') . "%Y')" .
"FROM $dayFileTableName " .
'GROUP BY intv ' .
'ORDER BY rain ' . ($dry ? 'ASC ' : 'DESC ') .
'LIMIT 10';
$result = mysql_query($query);
if (!$result) {
die('ERROR - Bad Select Statement (3) - <br>' . $query . '<br>'. $mysqli->error);
}
// import the rows and put the data into arrays
while ($row = mysql_fetch_row($result)) {
$rtn[] = $row;
}
return $rtn;
}

// Get the 10 dullest days
function minMaxSolarRad($rcnt) {
global $dayFileTableName;
$query = 'SELECT LogDate, ROUND(HighSolarRad,0), ' .
"Logdate >= DATE_SUB(CURDATE(), INTERVAL $rcnt DAY) " .
"FROM $dayFileTableName " .
'WHERE HighSolarRad > 0 ' .
'ORDER BY HighSolarRad ASC ' .
'LIMIT 10';
$result = mysql_query($query);
if (!$result) {
die('ERROR - Bad Select Statement (4) - <br>' . $query . '<br>'. $mysqli->error);
}
// import the rows and put the data into arrays
while ($row = mysql_fetch_row($result)) {
$rtn[] = $row;
}
return $rtn;
}


// End of the server side script
//###########################################################################################
// Start to build the page for the client
?>
<div id="content" style="min-width:680px">
<h1>Camberley weather</h1>
<h2 style="text-align: left; text-transform: none;">
&nbsp;Latitude&nbsp;N&nbsp;51&deg;&nbsp;19&#39;&nbsp;55&quot;&nbsp;&nbsp;&nbsp;&nbsp;Longitude&nbsp;W&nbsp;00&deg;&nbsp;45&#39;&nbsp;12&quot;&nbsp;&nbsp;&nbsp;&nbsp;Elevation&nbsp;268&nbsp;ft</h2>
</h2>
<p>This page shows some of the Top 10 highs and lows recorded by this weather station.
General records began on 10 December 2011.<br>
New records (within the last <?php echo ($recentHighlight-1) ?> days, current month, or current year) are highlighted in blue text.
The data is updated just after midnight each day.</p>
<table>
<tbody>
<?php
// Walk the data array X records at a time (5 sub-tables per row on the page)
$recs = count($dataArrays);
$currRec = 0; // current index into array
$currCell = 0; // current cell in row

while ($currRec < $recs) {
// is the current record a header?
if ($dataArrays[$currRec][0] % 100 === 0) {
// yes, so show a header row
if ($currCell > 0) {
// already in a data row, so end it for the new category
for ($x = $currCell; $x <= $cells; $x++) {
// add any empty cells to pad the row
echo '<td>&nbsp;</td>';
}
// end the row
echo '</tr>';
}
// display the header
echo '<tr><td colspan=' . $cells . ' class="header ' . '">' . $dataArrays[$currRec][1] . '</td></tr><tr>';
// start a new row
$currCell = 0;
} else {
// no it is a data record...
if ($currCell === 0) {
// first cell, so create a new row
echo '<tr>';
}
// so create an embedded table to display it
echo '<td class="' . $dataArrays[$currRec][5] . '"><table><caption>' . $dataArrays[$currRec][2] . '</caption><tbody>';
$num = count($dataArrays[$currRec][6]); // number of rows for this data table (may be less than 10)
for ($i = 0; $i < 10; $i++) {
// do we have any records left for this category?
if ($i < $num) {
// yep, so show them
//recent record?
$rcntClass = ($dataArrays[$currRec][6][$i][2] === '1' ? ' recent' : '');
echo ' <tr><td class="cell1' . $rcntClass . '">' . $dataArrays[$currRec][6][$i][1] . '</td><td class="cell2' . $rcntClass . '">' . $dataArrays[$currRec][6][$i][0] . '</td></tr>';
} else {
// nope, so display an empty pair of cells
echo ' <tr><td>&nbsp;</td><td>&nbsp;</td></tr>';
}
}
echo '</tbody></table></td>';
}
$currCell += 1;
if ($currCell > $cells) {
// we have filled a row
echo '</tr>';
// start a new one
$currCell = 0;
}
// next array record
$currRec += 1;
}
// Now just end the page structure
?>
</tbody>
</table>
<tr>
<td colspan="4" class="td_navigation_bar">:<a href="index.htm">now</a>: :<a href="gauges-ss.htm">gauges</a>: :<a href="today_yesterday.htm">today/yesterday</a>: :<a href="monthYear.htm">this&nbsp;month/this&nbsp;year</a>: :<a href="record.htm">records</a>: :<a href="monthlyrecord.htm">monthly&nbsp;records</a>: :<a href="systeminfo.htm">system&nbsp;info</a>: :<a href="trends.htm">trends</a>:
:<a href="meteogram.htm">48hr&nbsp;forecast</a>: :<a href="metoffice.htm">met&nbsp;office</a>: :<a href="seismic_monitor.htm">seismic&nbsp;monitor</a>: :<a href="NOAA.php">NOAA&nbsp;reports</a>: :<a href="winds.htm">wind&nbsp;map</a>:</td>
</tr>
<p class="credits"><br />
Page updated <?php echo date('d/m/Y H:i:s') ?><br>
powered by <a href="http://sandaysoft.com/products/cumulus" target="_blank">Cumulus</a><br>
<?php
//End of execution timer
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo '<br>This page was created in ' . Round($totaltime, 3) . ' seconds<br>';
echo 'The MySQL queries took ' . Round($totalSQLtime, 3) . ' seconds';
?>
</p>
</div> <!-- content -->
</body>
</html>






MeteoBisignano wrote:I uploaded the files have been found on the forum new2_php but now comes a new error
I proceeded to enter also suggested change but now it gives me this error: ERROR - Bad Select Statement (1) -
SELECT LogDate, ROUND(MinTemp, 1), Logdate >= DATE_SUB(CURDATE(), INTERVAL 8 DAY) FROM ./dayfile.txt WHERE MinTemp IS NOT NULL ORDER BY MinTemp ASC LIMIT 10

mcrossley wrote:
MeteoBisignano wrote:Hello friends are several days but I feel gives me this error:
ERROR - Bad Select Statement (1) - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Given that use a station WH 3080 with solar sensors

Change the line...

Code: Select all

die('ERROR - Bad Select Statement (1) - ' . $mysqli->error);

to...

Code: Select all

die('ERROR - Bad Select Statement (1) - <br>' . $query . '<br>'. $mysqli->error);


That will give you offending select statement, and you can try it in phpmyadmin.

User avatar
mcrossley
Posts: 5008
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Postby mcrossley » Mon Mar 09, 2015 1:14 pm

Folks, there is no need to keep posting the contents of the PHP file!

MeteoBisignano
Posts: 79
Joined: Mon Mar 09, 2015 10:45 am
Weather Station: wh3080
Operating System: windows
Location: Cosenza

Re: Top 10 Records Page

Postby MeteoBisignano » Mon Mar 09, 2015 1:15 pm

Last error:
ERROR - Bad Select Statement (1) -
SELECT LogDate, ROUND(MinTemp, 1), Logdate >= DATE_SUB(CURDATE(), INTERVAL 8 DAY) FROM dayfile.txt WHERE MinTemp IS NOT NULL ORDER BY MinTemp ASC LIMIT

Why?Where is the problem?

MeteoBisignano
Posts: 79
Joined: Mon Mar 09, 2015 10:45 am
Weather Station: wh3080
Operating System: windows
Location: Cosenza

Re: Top 10 Records Page

Postby MeteoBisignano » Mon Mar 09, 2015 1:16 pm

mcrossley wrote:Folks, there is no need to keep posting the contents of the PHP file!


I posted only to facilitate the search of the error

User avatar
mcrossley
Posts: 5008
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Top 10 Records Page

Postby mcrossley » Mon Mar 09, 2015 1:21 pm

MeteoBisignano wrote:Last error:
ERROR - Bad Select Statement (1) -
SELECT LogDate, ROUND(MinTemp, 1), Logdate >= DATE_SUB(CURDATE(), INTERVAL 8 DAY) FROM dayfile.txt WHERE MinTemp IS NOT NULL ORDER BY MinTemp ASC LIMIT

Why?Where is the problem?

I suspect your dayfile table is not called "dayfile.txt" ?

Code: Select all

$dayFileTableName = './dayfile.txt';

MeteoBisignano
Posts: 79
Joined: Mon Mar 09, 2015 10:45 am
Weather Station: wh3080
Operating System: windows
Location: Cosenza

Re: Top 10 Records Page

Postby MeteoBisignano » Mon Mar 09, 2015 1:28 pm

mcrossley wrote:
MeteoBisignano wrote:Last error:
ERROR - Bad Select Statement (1) -
SELECT LogDate, ROUND(MinTemp, 1), Logdate >= DATE_SUB(CURDATE(), INTERVAL 8 DAY) FROM dayfile.txt WHERE MinTemp IS NOT NULL ORDER BY MinTemp ASC LIMIT

Why?Where is the problem?

I suspect your dayfile table is not called "dayfile.txt" ?

Code: Select all

$dayFileTableName = './dayfile.txt';



This is the file loaded by Cumulus with all the data of the day
Or what should I do to x funzianre this script?
What should I put in the tag specified?
My file data is correct and is loaded on the root of the site by Cumulus
You may send in your own private setup?


Return to “Web site - General”

Who is online

Users browsing this forum: Bing [Bot] and 6 guests