Web Weather > Weather Website PHP/AJAX scripting
Replace Yesterday with Normal Hi/Lo for Day
greggw:
I am using the Saratoga PHP Template (Base-USA) with the Ambient Weather Network (AWN) plug-in. Everything is working fine. However, on the Home Page that reports current conditions, I would like to replace the "Yesterday" temperature with the "Normal High and Low" for the current day. Since I think normals are now fixed until 2030, the data could be read from a manually-created txt file without having to make a daily request to a NOAA website. Can anyone offer advice on how to do that? Thanks.
uziom:
To replace the "Yesterday" temperature with the "Normal High and Low" for the current day on the Home Page of your Saratoga PHP Template (Base-USA) with the Ambient Weather Network (AWN) plug-in, you would need to modify the PHP code that generates the weather data display.
Here are the general steps you can follow to achieve this:
Create a text file that contains the normal high and low temperatures for the current day. This file should be updated manually whenever there is a change in the normal temperatures.
Modify the PHP code that generates the weather data display on the Home Page to read the normal temperatures from the text file and display them in place of the "Yesterday" temperature.
To ensure that the normal temperatures are only displayed for the current day, you can use PHP's date functions to check the current date and only display the normal temperatures if they correspond to the current date.
Test the modified PHP code to ensure that it displays the normal temperatures correctly.
Here is an example code snippet that you can modify to read the normal temperatures from a text file:
--- Code: ---// Check if today's normal temperatures are available
$normal_temps_file = 'normal_temps.txt';
if (file_exists($normal_temps_file)) {
$normal_temps = file($normal_temps_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$normal_high = $normal_temps[0];
$normal_low = $normal_temps[1];
} else {
// Fall back to displaying yesterday's temperature if normal temps are not available
$normal_high = $yesterday_high;
$normal_low = $yesterday_low;
}
// Display the normal high and low temperatures
echo 'Normal High: ' . $normal_high . '°F<br>';
echo 'Normal Low: ' . $normal_low . '°F<br>';
--- End code ---
Note: This is just an example code snippet and may need to be modified to fit the specific structure of your PHP code. It's also important to ensure that the text file containing the normal temperatures is accessible by the PHP script and that the file path is correct in code.
greggw:
Thank you very much. I am new to all of this, as you can probably tell, since my post should have referenced my website at https://valleweather.com. The information you provided is very helpful and gives me a place to start. Thanks again for your help.
scudwatcher:
Since I could not get alt-dashboard 6.95h to configure and upload to my site in three attempts, I would LOVE to change my Saratoga base-USA TODAY and YESTERDAY High and Low Temps to NORMALS and RECORDS High and Low Temps. I am aware that I would have to modify ajax-dashboard php and some WD testtags in some fashion....any suggestions? I was successful in modifying my ajax-dashboard to change ALMANAC to SOIL TEMPS AND MOISTURES @ https://csraweather.org Thank You in advance!
92merc:
You could always ditch going through the dashboard and have a section under the dashboard.
https://www.wxforum.net/index.php?topic=37220.0
The temps on my site for "National Weather Service History" section is using this simple PHP program noaarec.php.
The rain part on my site is custom.
https://www.bismarckweather.net
Navigation
[0] Message Index
[#] Next page
Go to full version