Thanks Ray.
Your PHP script does not include any downloader
https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=16425, so I would not have been able to see the PHP script without you sharing it.
When I first applied for a job (many decades ago!), on my application I actually put "I do not want to work with computers", but of course from time to time in employment I did encounter them, in my case learning Fortran, Pascal, Cobol, BBC basic, Visual Basic, HP Basic, and a few others for various specific needs in the earlier part of my working career; after that I basically sat in front of a PC using standard applications and forgetting how to code. After retirement when I came to learn PHP it was hard, but essentially I bought a simple book and worked through its examples and then edited one of Mark's scripts for further practice before I ventured out on my own with first a daily summary type script and then the METAR scripts (very challenging and I developed my expertise), all mentioned elsewhere in the forum.
My suggestion is that you swap your source to
http://www.komokaweather.com/weather/da ... p?view=sce. That source, although it is on Paul's site, is by Mark Crossley and is the one referenced by
https://cumulus.hosiene.co.uk/viewtopic.p ... 319#p82284 i.e. the coloured version that the Wiki links to. As you may have discovered the link in that forum post no longer works as it was before Mark revamped his site. Hopefully, Paul's source (also now linked from Wiki) will work with almost no modification on your site, depending on which colour ranges you want. See lines 873 to 877:
Code: Select all
// temperature gradient colours for 4 ranges in Celsius
$tempGrad10to0 = gradient('54509F','00FFD4',100);
$tempGrad0to10 = gradient('00FFD4','48FF00',100);
$tempGrad10to20 = gradient('48FF00','FFDD00',100);
$tempGrad20to30 = gradient('FFDD00','FF0000',100);
If you do have problems, Mark may remember enough to sort you out, but if necessary I might find the time to compare your current source and Paul's ex-Mark source to work out any change needed if you cannot.
-----------------------------------------------------------------------------------------
I don't think persisting with your current script makes sense, and it is a long explanation that you do not need to read...
The relevant bit of code for defining whether to change colours is in lines 36 to 43:
Code: Select all
// use different colours for minimum/maximum/zero values - display the legends for the colours
$hilow = true;
// minimum/maximum values used to display data in different colours - '$hilow' must be set to true
$minTemp = '0'; // minimum temperature highlight
$maxTemp = '25'; // maximum temperature highlight
$maxRain = '0.5'; // maximum rain quantity highlight
$maxGust = '30'; // maximum wind gust speed highlight
Between reading a value and its output into the table your script for each such value determines if changing colour of output text is needed in lines 151 to 166:
Code: Select all
if ($whatdata =='rainfall' or $whatdata =='windgust') {
$value = floatval(str_replace(',','.',$data_arr[0]));
// set a class for rain or wind zero values
if ($value == 0) { $tablelayout .= ($hilow ? ' zerovalue2' : ' zerovalue'); }
// set a class for excessively wet days
if ($hilow and $whatdata =='rainfall' and $value >= $maxRain) { $tablelayout .= ' wetvalue'; }
// set a class for excessively windy/gusty days
if ($hilow and $whatdata =='windgust' and $value >= $maxGust) { $tablelayout .= ' gustvalue'; }
}
if ($whatdata == 'maxtemp' or $whatdata == 'mintemp' or $whatdata == 'avgtemp' or $whatdata == 'minmaxt') {
$value = floatval(str_replace(',','.',$data_arr[0]));
// set a class for low temperature values - check if we have two sets of data
if ($hilow and $value <= $minTemp) { $tablelayout .= ($dayfilecol2 > 0 ? ' lowvalue2' : ' lowvalue'); }
// set a class for high temperature values - check if we have two sets of data
if ($hilow and $value >= $maxTemp) { $tablelayout .= ($dayfilecol2 > 0 ? ' highvalue2' : ' highvalue'); }
}
Line 160:
Code: Select all
if ($whatdata == 'maxtemp' or $whatdata == 'mintemp' or $whatdata == 'avgtemp' or $whatdata == 'minmaxt') {
This is the if statement relevant to temperature. The $whatdata is a variable that holds what you have selected to display in the table, so this code is obeyed for displaying either the minimum temperature, or the maximum temperature, or the minimum temperature on the left and the maximum on the right per table cell pair for a particular day of the year.
Line 161: Don't worry about this, it is basically changing a comma representing the boundary between integer and decimal parts of a floating format into a full stop, i.e. how you or I would write a real number.
Line 165:
Code: Select all
if ($hilow and $value >= $maxTemp) { $tablelayout .= ($dayfilecol2 > 0 ? ' highvalue2' : ' highvalue'); }
This somewhat convoluted code is what tests the magnitude of the value and decides if colour is to be applied because it is a high value. It is nothing like what we met in Visual Basic! Let me dissect it,
this checks the value set in line 37, it is true, so that is noted and the next part of the condition is examined.
This says the next bit must also be true or the script will move to next statement.
This compares the left hand value (the only value unless both min and max are being shown) with the threshold defined in line 41. If that condition is also true, a space and then the class
highvalue is added to the instructions for how to format the table cell - see
.
However, if there are two figures being shown per day of year, the variable $dayfilecol2 is true and this is tested by
If that is true then the class
highvalue2 is added to the instructions for how to format the table cell - see
.
OK, I explain all that to show what you want to achieve is far from simple with the way that the script you are using is written. You would need something like 165 for each different colour:
Code: Select all
if($hilow and $value > $lowEndOfRange1 and$value <= $highEndOfRange1)
This would probably be implemented within a loop, and the range values defined in an array. For greater efficiency, the $hilow would not be repeated, the $whatdata would be tested by using the
switch(){}construct and you can see it is quite a large rewrite, and not a short job, so forget attempting that.