Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Rolling Weekly Data - Displaying data on website

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

Moderator: daj

Palmyweather
Posts: 52
Joined: Sat 28 Nov 2009 9:57 am
Weather Station: W1081
Operating System: Windows 7
Location: New Zealand
Contact:

Rolling Weekly Data - Displaying data on website

Post by Palmyweather »

Hi everyone

One of my website users has asked if I could display a rolling weekly data set which will show the minimum and maximum of various measurements like temperature, wind, rain etc. For example if today if Friday, the report would show data for today and the past days to Friday last week. Then tomorrow it would do the same for Saturday. Similar to the "today" and "yesterday" summary report in the original Cumulus templates.

Before I reinvent the wheel, is this something someone has already done?
What would the best option be to create such a report?
Could this be a development feature for CumulusMX? For example, having such a report produced as part of the NOAA reports or webtags which could be used?

I was thinking about creating a PHP file which write a new line of code each day while deleting the first line. I have similar scripts working on my site already. But then again, there is already data sets from Cumulus like this which we could extract the data from. For example, read the last 7 entries of the "dayfile.txt". Only thing is, my "dayfile.txt" is now over 1MB with data dating back to 2009 so a bit clunky to read every time it needs to get data.

Then comes the formatting of the data once any file is read and calculating the averages for the progressing week. There could be up to 144+ data entries to manage. I have attached an example table for some clarification to the above query.

What do you guys think? Is this achievable and would it be useful?

Thanks for your help and feedback,
Matt
You do not have the required permissions to view the files attached to this post.
Check my Palmerston North, New Zealand weather station out at https://palmyweather.co.nz .

Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Rolling Weekly Data - Displaying data on website

Post by sfws »

I did this a decade ago when I used Cumulus 1 (my data started in 2009 too), and my web page showing the last week of derivatives is still my most heavily used web page.
As an old page, it is still written as a Cumulus template although generating PHP code. I did post an outline on the appropriate sub-forum at time, I forget the topic title, but it may have mentioned "'a year ago" as it was a general idea for any number of past days reading dayfile.txt (using JavaScript originally, later modified to use PHP and multiple database tables). It may be my post is still referenced from Wiki as one option for summary of daily data. I really am in middle of something and can't spend any time searching. A "holiday project" has only just started that is changing my scripts and database tables, so it is possible some content will be wrong in the image attached (of part of my web page), and I currently have some layout issues that are making table cells much larger than content, so limiting number of rows seen, but they say a picture is worth hundreds of words?


Do you have a database table with one row per day?
If so, you can basically compose SQL in PHP to read numbers off that and put them into web page table. That is easier than reading dayfile.txt which is what my script originally did.
There is no point in me sharing my script, it is now part of a suite and totally unsuitable for viewing in isolation, plus you have picked the worst possible day to ask me as nothing is static this long weekend!
You do not have the required permissions to view the files attached to this post.
User avatar
PaulMy
Posts: 3777
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by PaulMy »

Hi Matt,
I like that idea... it reminds be of one of my initial scripts I created with webtags when I first learned about Cumulus many years ago http://www.komokaweather.com/weather/Ko ... mpare.html and I haven't improved since :oops:

Then borrowed Ace2's Observation where he created something a little different using the <#recent**** and (d)ay and (t)ime parameters http://www.komokaweather.com/weather/obe.htm#Navigation

Enjoy,
Paul
Davis Vantage Pro2+
C1 www.komokaweather.com/komokaweather-ca
MX www.komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX www.komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX www. komokaweather.com/cumulusmx4/index.htm

Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Rolling Weekly Data - Displaying data on website

Post by sfws »

Thanks Paul, useful to see your two tables, you have jogged my memory enough for me to check the notes on my web page, (now I have decided to stop making database table changes, and leave further script and web page changes until tomorrow).

My current script says, this version dates from February 2013 (I said it was old, and that confirms I had a different design earlier), and my page has a reference to another New Zealand site http://wairoa.net/weather/week.htm saying that although I worked independently, sadly I had not come up with a novel idea. It also says (written 9 years ago) I had checked a lot of Cumulus sites and not found any others implementing the idea, (so apparently I missed yours, that you did many years ago).


I have also confirmed that it was sometime during 2014 when I swapped from accessing the dayfile.txt using JavaScript to using PHP and database tables, so that is probably when I last posted anything about it in forum.

Since then the script has continued to use a mixture of jQuery, JavaScript, sparkline.js, highstock, and PHP. Note, it always has used some "recent history" web tags, as although not really evident in my screen shot, I compare current spot temperatures, pressure, etc. with readings for the same time in preceding 6 or 7 days (it shows a different number of days before and after rollover).

When I swapped to MX in May 2020, I added extra access to "today.ini", "month.ini", "cumulusMX.db" and "diary.db" to make what potentially shown on the web page as comprehensive in its coverage as possible, yet some data is initially hidden.

My web page still has a somewhat odd mixture of web tags directly, web tags via templates setting PHP variables from web tags, plus various calculations to derive some extra derivatives. I have done some fairly cosmetic minor edits this year, improving the display for rainfall (first and last tip times added), and adding extra derivatives like daily pressure range, but never got around to any significant rewriting, normally I am too busy gardening, or walking, or decorating, to spend time on web page re-designing!
Palmyweather
Posts: 52
Joined: Sat 28 Nov 2009 9:57 am
Weather Station: W1081
Operating System: Windows 7
Location: New Zealand
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by Palmyweather »

Thanks everyone for your feedback.

Yes, I do have an SQL database which logs the data daily - temporarily forgot a database would be a much better approach to extracting the data, especially as it is already sitting there with little use.

The mentioned Weekly Weather report from Wairoa (http://wairoa.net/weather/week.htm) is very similar table design, but rather than comparing data at 8am each day, I would want the min and max of each day, like a midnight roll-over.

I very much like Paul's example (http://www.komokaweather.com/weather/Ko ... mpare.html) and it gives me an idea of how to display the units of measure with its own column and this table covers the datasets I'd like to try and display.

I guess I had better try and refresh my SQL memory and see what I can do. I think PHP and SQL will be the best way to go.

Thanks for your help,
Matt
Check my Palmerston North, New Zealand weather station out at https://palmyweather.co.nz .

Image
Palmyweather
Posts: 52
Joined: Sat 28 Nov 2009 9:57 am
Weather Station: W1081
Operating System: Windows 7
Location: New Zealand
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by Palmyweather »

Well I am pleased to report in just under one week I have managed to achieve what I set out to do, thanks to you guys help and ideas.

I'm not much of a programmer, but I was able to pull data from the database I already had set up and was able to put it into a table for display with support of cumulus webtags for today's data.

In fact, I was able to create it so with a change of a number, the amount of data to be displayed can be changed. Originality I set out to display just 7 days of data, but I have decided to use a 30 day rolling view on my site too.

The programming displays an average for the X number of days displayed and also indicates the trending difference on the previous X number of days.

These tables can now be seen on my website on such pages as: http://palmyweather.co.nz/table.php

The 7 day table displays 210 different data numbers over 21 categories.

I've learned a lot in doing this and it has been a help with my knowledge of PHP and SQL. I am sure there are be much better ways to program this PHP script than the way I have done. I have added the PHP code to this post for others to use if they like; I have used a lot of other peoples' scripts and code over the years so it is nice to give a little back.

Code: Select all

<?php 
//Include cumulus web tags file for "Today's" data
include_once("../cumuluswebtags.php"); ?>

<?php
//Include settings file OR hard code them into this page with the commented out settings below
include ('db_settings_details.php');
/* 
$servername = "localhost"; // The server host name running MySQL database
$username = ""; // The username used to log-in to your database server
$password = ""; // The password used to log-in to your database server
$dbname = ""; // The name of the MySQL database we will store the tables in
$dbtable = "daydata"; // The name of the table being accessed 
*/

// Set the period to be displayed
$dbrecordqty = "7"; // Set the number of records to display
$dbrecordqtytweek = $dbrecordqty *2; // Used for averaging. Set the number of records to compare against. Usually 2x the displayed data

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
?> 

<style>
	.rollingaverage {
		border:1px solid #C0C0C0;
		border-collapse:collapse;
		border:2px solid #8f8f8f;
		white-space: nowrap;
		font-family: Verdana, arial, Arial, Helvetica, Verdana, sans-serif;
		font-size: 10pt;
		color: #333333;
	}
	.rollingaverage th {
		border:1px solid #C0C0C0;
		background:#F0F0F0;
		font-family: Verdana, arial, Arial, Helvetica, Verdana, sans-serif;
		font-size: 10pt;
		color: #333333;
	}
	.rollingaverage td {
		border:1px solid #C0C0C0;
		font-family: Verdana, arial, Arial, Helvetica, Verdana, sans-serif;
		font-size: 10pt;
		color: #333333;
	}
	caption {
		font-size: 1em;
		font-style: normal;
		font-weight: bold;
		letter-spacing: .1em;
		padding-top: 0.5em;
		padding-bottom: 0.25em;
		text-align: left;
}
</style>
<table class="rollingaverage">	<caption>Rolling <?php echo "$dbrecordqty"; ?> Day Data</caption>
		<th style="border-bottom:2px solid #8f8f8f;">Data</th>
		<th style="border-right:2px solid #8f8f8f; border-bottom:2px solid #8f8f8f;">Unit</th>
		<th style="border-bottom:2px solid #8f8f8f;">Today<sup>*</sup></th>
		<?php
		//Get date from database. Limit to X entries for the weekly table
		$sql = "SELECT LogDate FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			  $date_old = $row["LogDate"]; 
		//Format date for display
		$dateformatted = date ('d/m/y', strtotime($date_old));
		$dayformatted = date ('D', strtotime($date_old));
		//Output data for display
		echo "<th style='border-bottom:2px solid #8f8f8f;'>" . $dayformatted. "<br/>" . $dateformatted. "</th>";
		}
		?>
		<th style='border-left:2px solid #8f8f8f; border-bottom:2px solid #8f8f8f;'><?php echo "$dbrecordqty"; ?> Day<br/>Average<sup>*</sup></th>
		<th style="border-bottom:2px solid #8f8f8f;">Trend on <br/>previous <br/><?php echo "$dbrecordqty"; ?> days<sup>*</sup></th>
	</tr>
	</thead>
	<tbody>
	<tr>
		<td>High Temperature</td>
		<td style="border-right:2px solid #8f8f8f;">&deg;C</td>
		<td><?php echo "$tempTH"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT MaxTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["MaxTemp"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT MaxTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["MaxTemp"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT MaxTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["MaxTemp"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>Low Temperature</td>
		<td style="border-right:2px solid #8f8f8f;">&deg;C</td>
		<td><?php echo "$tempTL"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT MinTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["MinTemp"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT MinTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["MinTemp"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT MinTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["MinTemp"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>High Apparent Temp.</td>
		<td style="border-right:2px solid #8f8f8f;">&deg;C</td>
		<td><?php echo "$apptempTH"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT HighAppTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["HighAppTemp"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT HighAppTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["HighAppTemp"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT HighAppTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["HighAppTemp"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>Low Apparent Temp.</td>
		<td style="border-right:2px solid #8f8f8f;">&deg;C</td>
		<td><?php echo "$apptempTL"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT LowAppTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["LowAppTemp"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT LowAppTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["LowAppTemp"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT LowAppTemp FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["LowAppTemp"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>Low Wind Chill</td>
		<td style="border-right:2px solid #8f8f8f;">&deg;C</td>
		<td><?php echo "$wchillTL"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT LowWindChill FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["LowWindChill"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT LowWindChill FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["LowWindChill"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT LowWindChill FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["LowWindChill"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>High Heat Index</td>
		<td style="border-right:2px solid #8f8f8f;">&deg;C</td>
		<td><?php echo "$heatindexTH"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT HighHeatind FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["HighHeatind"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT HighHeatind FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["HighHeatind"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT HighHeatind FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["HighHeatind"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>High Dew Point</td>
		<td style="border-right:2px solid #8f8f8f;">&deg;C</td>
		<td><?php echo "$dewpointTH"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT HighDewPoint FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["HighDewPoint"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT HighDewPoint FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["HighDewPoint"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT HighDewPoint FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["HighDewPoint"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>Low Dew Point</td>
		<td style="border-right:2px solid #8f8f8f;">&deg;C</td>
		<td><?php echo "$dewpointTL"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT LowDewPoint FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["LowDewPoint"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT LowDewPoint FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["LowDewPoint"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT LowDewPoint FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["LowDewPoint"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td style="border-top:2px solid #8f8f8f;">High Humidity</td>
		<td style="border-top:2px solid #8f8f8f; border-right:2px solid #8f8f8f;">%</td>
		<td style="border-top:2px solid #8f8f8f;"><?php echo "$humTH"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT HighHum FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td style='border-top:2px solid #8f8f8f;'>" .$row["HighHum"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT HighHum FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["HighHum"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;border-top:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT HighHum FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["HighHum"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green;border-top:2px solid #8f8f8f;'>+" .$trend. "</td>";}
		else {echo "<td style='color:red;border-top:2px solid #8f8f8f;'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>Low Humidity</td>
		<td style="border-right:2px solid #8f8f8f;">%</td>
		<td><?php echo "$humTL"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT LowHum FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["LowHum"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT LowHum FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["LowHum"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT LowHum FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["LowHum"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td style="border-top:2px solid #8f8f8f;">Rainfall</td>
		<td style="border-top:2px solid #8f8f8f; border-right:2px solid #8f8f8f;">mm</td>
		<td style="border-top:2px solid #8f8f8f;"><?php echo "$rfall"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT TotRainFall FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td style='border-top:2px solid #8f8f8f;'>" .$row["TotRainFall"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT TotRainFall FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["TotRainFall"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;border-top:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT TotRainFall FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["TotRainFall"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green;border-top:2px solid #8f8f8f;'>+" .$trend. "</td>";}
		else {echo "<td style='color:red;border-top:2px solid #8f8f8f;'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td style="border-top:2px solid #8f8f8f;">Max Wind Gust</td>
		<td style="border-top:2px solid #8f8f8f; border-right:2px solid #8f8f8f;">km/h</td>
		<td style="border-top:2px solid #8f8f8f;"><?php echo "$wgustTM"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT HighWindGust FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td style='border-top:2px solid #8f8f8f;'>" .$row["HighWindGust"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT HighWindGust FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["HighWindGust"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;border-top:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT HighWindGust FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["HighWindGust"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green;border-top:2px solid #8f8f8f;'>+" .$trend. "</td>";}
		else {echo "<td style='color:red;border-top:2px solid #8f8f8f;'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>Max Average Speed</td>
		<td style="border-right:2px solid #8f8f8f;">km/h</td>
		<td><?php echo "$windTM"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT HighAvgWSpeed FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["HighAvgWSpeed"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT HighAvgWSpeed FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["HighAvgWSpeed"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT HighAvgWSpeed FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["HighAvgWSpeed"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>Wind Run</td>
		<td style="border-right:2px solid #8f8f8f;">km</td>
		<td><?php echo "$windrun"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT TotWindRun FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["TotWindRun"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT TotWindRun FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["TotWindRun"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT TotWindRun FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["TotWindRun"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>Wind bearing</td>
		<td style="border-right:2px solid #8f8f8f;">&deg;</td>
		<td><?php echo "$domwindbearing"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT DomWindDir FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["DomWindDir"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT DomWindDir FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["DomWindDir"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT DomWindDir FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["DomWindDir"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		echo "<td>" .number_format((float)$lastweekaverage, 1, '.', ''). "</td>";
		?>
	</tr>
	<tr>
		<td>Wind Direction</td>
		<td style="border-right:2px solid #8f8f8f;">-</td>
		<td><?php echo "$domwinddir"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT HwindGBear FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["HwindGBear"]. "</td>";
		}
		?>
		<td  style="border-left:2px solid #8f8f8f;">
		<?php
		if ($calcaverage >=0 && $calcaverage <11.25){echo "N";}
		if ($calcaverage >11.25 && $calcaverage <33.75){echo "NNE";}
		if ($calcaverage >33.75 && $calcaverage <56.25){echo "NE";}
		if ($calcaverage >56.25 && $calcaverage <78.75){echo "ENE";}
		if ($calcaverage >78.75 && $calcaverage <101.25){echo "E";}
		if ($calcaverage >101.25 && $calcaverage <123.75){echo "ESE";}
		if ($calcaverage >123.75 && $calcaverage <146.25){echo "SE";}
		if ($calcaverage >146.25 && $calcaverage <168.75){echo "SSE";}
		if ($calcaverage >168.75 && $calcaverage <191.25){echo "S";};
		if ($calcaverage >191.25 && $calcaverage <213.75){echo "SSW";}
		if ($calcaverage >213.75 && $calcaverage <236.25){echo "SW";}
		if ($calcaverage >236.25 && $calcaverage <258.75){echo "WSW";}
		if ($calcaverage >258.75 && $calcaverage <281.25){echo "W";}
		if ($calcaverage >281.25 && $calcaverage <303.75){echo "WNW";}
		if ($calcaverage >303.75 && $calcaverage <326.25){echo "NW";}
		if ($calcaverage >326.25 && $calcaverage <348.75){echo "NNW";}
		if ($calcaverage >348.75 && $calcaverage <371.25){echo "N";}
		?>
		</td>
		<td>
		<?php
		if ($lastweekaverage >=0 && $lastweekaverage <11.25){echo "N";}
		if ($lastweekaverage >11.25 && $lastweekaverage <33.75){echo "NNE";}
		if ($lastweekaverage >33.75 && $lastweekaverage <56.25){echo "NE";}
		if ($lastweekaverage >56.25 && $lastweekaverage <78.75){echo "ENE";}
		if ($lastweekaverage >78.75 && $lastweekaverage <101.25){echo "E";}
		if ($lastweekaverage >101.25 && $lastweekaverage <123.75){echo "ESE";}
		if ($lastweekaverage >123.75 && $lastweekaverage <146.25){echo "SE";}
		if ($lastweekaverage >146.25 && $lastweekaverage <168.75){echo "SSE";}
		if ($lastweekaverage >168.75 && $lastweekaverage <191.25){echo "S";};
		if ($lastweekaverage >191.25 && $lastweekaverage <213.75){echo "SSW";}
		if ($lastweekaverage >213.75 && $lastweekaverage <236.25){echo "SW";}
		if ($lastweekaverage >236.25 && $lastweekaverage <258.75){echo "WSW";}
		if ($lastweekaverage >258.75 && $lastweekaverage <281.25){echo "W";}
		if ($lastweekaverage >281.25 && $lastweekaverage <303.75){echo "WNW";}
		if ($lastweekaverage >303.75 && $lastweekaverage <326.25){echo "NW";}
		if ($lastweekaverage >326.25 && $lastweekaverage <348.75){echo "NNW";}
		if ($lastweekaverage >348.75 && $lastweekaverage <371.25){echo "N";}
		?>
		</td>
	</tr>
	<tr>
		<td style="border-top:2px solid #8f8f8f;">High Pressure</td>
		<td style="border-top:2px solid #8f8f8f; border-right:2px solid #8f8f8f;">hPa</td>
		<td style="border-top:2px solid #8f8f8f;"><?php echo "$pressTH"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT MaxPress FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td style='border-top:2px solid #8f8f8f;'>" .number_format((float)$row["MaxPress"], 1, '.', ''). "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT MaxPress FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["MaxPress"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;border-top:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT MaxPress FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["MaxPress"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green;border-top:2px solid #8f8f8f;'>+" .$trend. "</td>";}
		else {echo "<td style='color:red;border-top:2px solid #8f8f8f;'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>Low Pressure</td>
		<td style="border-right:2px solid #8f8f8f;">hPa</td>
		<td><?php echo "$pressTL"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT MinPress FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .number_format((float)$row["MinPress"], 1, '.', ''). "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT MinPress FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["MinPress"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT MinPress FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["MinPress"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td style="border-top:2px solid #8f8f8f;">Sun Hours</td>
		<td style="border-top:2px solid #8f8f8f; border-right:2px solid #8f8f8f;">hours</td>
		<td style="border-top:2px solid #8f8f8f;"><?php echo "$SunshineHours"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT HoursSun FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td style='border-top:2px solid #8f8f8f;'>" .$row["HoursSun"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT HoursSun FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["HoursSun"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;border-top:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT HoursSun FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["HoursSun"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green;border-top:2px solid #8f8f8f;'>+" .$trend. "</td>";}
		else {echo "<td style='color:red;border-top:2px solid #8f8f8f;'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>Solar Radiation</td>
		<td style="border-right:2px solid #8f8f8f;">W/m<sup>2</sup></td>
		<td><?php echo "$solarTH"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT HighSolarRad FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["HighSolarRad"]. "</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT HighSolarRad FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["HighSolarRad"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT HighSolarRad FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["HighSolarRad"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tr>
		<td>UV Index</td>
		<td style="border-right:2px solid #8f8f8f;">UVI</td>
		<td><?php echo "$UVTH"; ?></td>
		<?php
		//Get date from database. Limit to X entries for the weekly table and display them all sequentially
		$sql = "SELECT HighUV FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
		//Output data for display
		echo "<td>" .$row["HighUV"]. "0</td>";
		}
		?>
		<?php
		//Get date from database. Limit to X entries for the weekly table and average them to one data result
		$sql = "SELECT HighUV FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;
		$result = $conn->query($sql);
		$calcaverage=0;
		  while($row = $result->fetch_assoc()) {
			$calcaverage=  $calcaverage + $row["HighUV"];
			}  
			$calcaverage = $calcaverage / $dbrecordqty;
			$trendthisweek= $calcaverage;
		//Output data for display
		echo "<td style='border-left:2px solid #8f8f8f;'>" .number_format((float)$calcaverage, 1, '.', ''). "</td>";
		?>
		<?php
		//Get date from database. Get data for last X*2 days. Compare for trend from above average by creating an average.
		$lastweekaverage = array(); // create a variable to hold the information
		$sql = "SELECT HighUV FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqtytweek; 
		$result = $conn->query($sql);
		  while($row = $result->fetch_assoc()) {
			$lastweekaverage[] = $row["HighUV"];
			}  
		//Now you have X*2 days worth of data, delete first X days to get last week before averaging. Then subtract "this week" from "last week"
		$x = 0;
		while($x != $dbrecordqty) {
		  unset($lastweekaverage[$x]);
		  $x++;
		} 
		$lastweekaverage=(array_sum($lastweekaverage));
		$lastweekaverage = $lastweekaverage/$dbrecordqty;
		$trend = $trendthisweek - $lastweekaverage;
		$trend = number_format((float)$trend, 2, '.', '');
		//Check to see if positive or negative number and add a leading + and change colour accordingly
		if ($trend>=0){echo "<td style='color:green'>+" .$trend. "</td>";}
		else {echo "<td style='color:red'>" .$trend. "</td>";}
		?>
	</tr>
	<tbody>
</table>
<sup>*</sup> Today's data set is incomplete. Averages and trends do not include today's data.
 <?php
$conn->close();
?> 
You do not have the required permissions to view the files attached to this post.
Last edited by Palmyweather on Thu 21 Apr 2022 11:17 am, edited 2 times in total.
Check my Palmerston North, New Zealand weather station out at https://palmyweather.co.nz .

Image
User avatar
PaulMy
Posts: 3777
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by PaulMy »

Excellent!

Enjoy,
Paul
Davis Vantage Pro2+
C1 www.komokaweather.com/komokaweather-ca
MX www.komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX www.komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX www. komokaweather.com/cumulusmx4/index.htm

Image
Mapantz
Posts: 1778
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by Mapantz »

That's really nifty! :clap:

I'd like to be able to use this, if that's OK? The data in this form would be really useful for me.

I'm in the middle of creating a credits page on my site, so of course, I would add you to it..

PS: I've just tested it and changed a few things to connect to my data base, and spotted a small error:

LowDewPint needs to be amended to LowDewPoint :P

But, it works good!
Image
Palmyweather
Posts: 52
Joined: Sat 28 Nov 2009 9:57 am
Weather Station: W1081
Operating System: Windows 7
Location: New Zealand
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by Palmyweather »

Yes, you are welcome to use it. It may need some modification depending on your needs and how individual databases are set-up. Hope it will work for most without people needing to change too much.

RE: LowDewPint needs to be amended to LowDewPoint . Good spotting. You'd think the word "point" would be spelt correctly, but for some reason in my database it is "pint" for what ever reason. When spelt correctly, it threw up errors and I needed to check the database and found the misspelling.
Check my Palmerston North, New Zealand weather station out at https://palmyweather.co.nz .

Image
Mapantz
Posts: 1778
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by Mapantz »

Palmyweather wrote: Wed 20 Apr 2022 7:53 pm Yes, you are welcome to use it. It may need some modification depending on your needs and how individual databases are set-up. Hope it will work for most without people needing to change too much.

RE: LowDewPint needs to be amended to LowDewPoint . Good spotting. You'd think the word "point" would be spelt correctly, but for some reason in my database it is "pint" for what ever reason. When spelt correctly, it threw up errors and I needed to check the database and found the misspelling.
:lol:

Well, it works perfect! I am always referring to my stats for certain purposes, and this will prove to be very useful, due to 7 days being all in one table.

Thank you!
Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Rolling Weekly Data - Displaying data on website

Post by sfws »

I find your new web page impressive (and you were quick to achieve as much as that if this is your first significant php and SQL project).

Re "DewPint", this spelling was a bug created by the Cumulus SQL developer, so you obviously did not correct the column name when the 29 March 2013, release announcement said it needed changing.

Thanks for sharing your code. You have written a separate query for each line in your HTML table. If you later need to change something, that is a lot of queries that you have to edit. That represents one big difference between my approach and yours, that you might want to think about. (I am not saying you are wrong, but there is a principle in programming called DRY - don't repeat yourself - and although my coding is mostly self-taught, I tend now when I revisit code to make each little bit of code I write as simple as possible, so rather than typing something similar in again, some code is in separate scripts I can require/include wherever I need it, other code is in functions if I need to pass parameters to make it adjust to each context!)

My approach listed as steps in attachment may seem daunting, but actually the only difference is that it avoids all the line by line repetition you coded by defining a simple generic row and a single query .

[EDIT - moved the steps that originally followed here into attachment, and made mention of it in paragraph above]
You do not have the required permissions to view the files attached to this post.
Last edited by sfws on Sun 24 Apr 2022 8:04 am, edited 1 time in total.
User avatar
HansR
Posts: 5871
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by HansR »

Discussion point:

I admire inventive programming but this (previous post by @sfws) explains precisely why I think users need to be divided in two classes:
  1. Those who use CMX as a source for programming a website in any way imaginable
  2. Those who wish to use CMX as a source for meteorological data (specific to a location) and present those to the world
It is very fine when both approaches are served well both by CMX, by the forum and by the Wiki and I think up to a certain level that goal is met.

However, I think, that a distinction should be made more clearly so not to frighten off (new) users who may not be scared by computers and configuration but do not wish to or are scared off by programming. Searching on the forum does not really make that distinction so when looking for how to use CMX users may be pulled into a direction they are not prepared to take and therefore let it go.

So when applied to @sfws's post, and maybe even the whole thread, I would suggest to keep such communication to specific a thread (e.g. programming tips and tricks) and not in a forum called General. This is NOT general information, this is very specific programming with the use of SQL which requires quite some work around it.

Please.
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
griffo42
Posts: 226
Joined: Thu 10 Dec 2015 6:41 am
Weather Station: Davis Vantage Pro2
Operating System: Win 11 Home
Location: Brisbane, Queensland, Australia
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by griffo42 »

I see that some other members have implemented this script, apparently, without problems or perhaps using expertise that I don't have.

I tried to implement "as is" with the few required chnages but I got no result. I finally then cut the code back to sorting out the 7 dates but to no avail.

What I get is:
Screenshot 2022-04-24 165720.png
The coding that I have to get to there is in the zip file attached.

Any help to progress this would be appreciated.

Keith
You do not have the required permissions to view the files attached to this post.
Keith
Davis Vantage Pro2 Model #6152AU - CumulusMX - Win11 - Saratoga/CUMX Default Scripts
https://www.kstwx.net/index.php
https://www.kstwx.net/cumx/index.html
Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Rolling Weekly Data - Displaying data on website

Post by sfws »

Keith

To see error messages, modify your line 1 to read

Code: Select all

<?php  error_reporting(E_ALL);
I have run your script on my own web server, against my database table and it works, I see the table and a row of eleven cells with dates as expected, that means your problem lies within one of the lines that relate specifically to your database table.

Thank you for including a screen image, that tells me, on your server, only the first 2 table cells appear.
That means any error is BEFORE the next output "echo "<th style='border-bottom:2px solid #8f8f8f;'>" . $dayformatted. "<br/>" . $dateformatted. "</th>";"

So let us methodically work through lines relating to your database:
1) I assume you have correct content for the lines defining $username to $dbtable, but you should check those, as obviously they had to be changed for my test.
2) All except the last of those should be correct, otherwise you would see the message you have declared at line 26 to display "die("Connection failed: " . $conn->connect_error);", so do make a further check of $dbtable = "dayfilecumx";
3) The query at line 69 "$sql = "SELECT LogDate FROM ". $dbtable ." ORDER BY LogDate DESC LIMIT ". $dbrecordqty;" is fine, that works on my test.
4) If the query was wrong for you, you would get a message from line 71 "if (!$result) die($connection->error);"
5) There could be a failure at line 73 "$date_old = $row["LogDate"];", if your database table was empty
6) Without seeing the actual error message, (see my first suggestion), and without seeing your database table, this could be your problem.
Hopefully, you say thank you now, and don't read anymore (except perhaps my final comment)!
7) Ideally, the code should test for an empty query result, perhaps include this line after your line 71, before the loop

Code: Select all

$db_row_count = 	mysqli_num_rows($result);
if(!$db_row_count) exit('Database table ' . $dbtable . ' has no rows');
8) Moving on, line 75 "$dateformatted = date ('d/m/y', strtotime($date_old));" will fail if whatever you have in the "LogDate" column of the most recent row is not recognised as a date. If you post the contents of your most recent row in your table, then that can be eliminated.

It is very very unlikely, that you have problems with the PHP and MySQL software that your host provides, I just include a mention of it for completeness! Some versions of PHP might have a bug relating to some part of the date functionality, so line 75 fails because, at run-time, it cannot be parsed. If your database table is fine, then to test your PHP, you could try replacing lines 75 and 76 with

Code: Select all

$dateInstance	 =  	new DateTime($date_old);
$dateformatted = $dateInstance->format('Y-m-d');
$dayformatted = $dateInstance->format('D');
(I enjoyed reading about Brisbane on your web site, I have never visited it, but someone who came for a few months to the UK before having children, and worked with me back then, lives in a NE suburb. Although we long ago abandoned contact, your notes made me recall some memories of what she told me about Queensland and the photos she sent me !)
Last edited by sfws on Wed 27 Apr 2022 6:27 am, edited 1 time in total.
griffo42
Posts: 226
Joined: Thu 10 Dec 2015 6:41 am
Weather Station: Davis Vantage Pro2
Operating System: Win 11 Home
Location: Brisbane, Queensland, Australia
Contact:

Re: Rolling Weekly Data - Displaying data on website

Post by griffo42 »

@sfws

Thanks for your help with my problem.

I think that have implemented the changes to my script that you suggested. A new Zipped copy is attached. It doesn't seem to have achieved the result we both are looking for as evidenced by this new screenshot taken today (25Apr):
Screenshot 2022-04-25 124134 25apr.png
In reading this BB plus others and not being an expert in these matters, it seems that my problem my be with the version of MySql used by my ISP (Host Papa). To throw light on this aspect, this screenshot may be of assistance:
Screenshot 2022-04-25 131807dbdetails.png

In relation to the matter of whether the required information is in my dbtable, here is a screenshot of that. The table was prepared by using the utility provided by @mcrossley and seems to have the necessary data in it in the expected format.
dayfilecumxscreenshot.png
BTW, thanks for your supportive comments about my "place of abode". My forebears arrived here in 1842, so we have a very long connection with Brisbane!

Keith
You do not have the required permissions to view the files attached to this post.
Keith
Davis Vantage Pro2 Model #6152AU - CumulusMX - Win11 - Saratoga/CUMX Default Scripts
https://www.kstwx.net/index.php
https://www.kstwx.net/cumx/index.html
Image
Post Reply