Author Topic: AjaxDashboard  (Read 839 times)

0 Members and 1 Guest are viewing this topic.

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1314
  • BismarckWeather.net
    • BismarckWeather.net
AjaxDashboard
« on: May 08, 2017, 05:24:31 PM »
At the bottom of my main ajaxdashboard, I've added in the Record and Normal high temps obtained from WU.

But I'd like to add in one other section.  The one part is real easy.  I figured out how to just use php includes to add in the text value I have in a rainmo.txt file and rainytd.txt file for what is normal for this month in rain and what is normal for YTD in rain.

Before I go ahead and add that in, is there a way to also add in another line that will take the value from each file and give me a "departure from normal"?  It would be basically just subtracting the value from the text file from the actual value already reporting in the dashboard.

Hoping someone with some PHP knowledge can help out.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1314
  • BismarckWeather.net
    • BismarckWeather.net
Re: AjaxDashboard
« Reply #1 on: May 10, 2017, 01:28:46 PM »
Well, I'm not a PHP programmer by any means, but here's what I did.  I already had the WU section added in around line 980 in my ajaxdashboard.php file.  This is what I added in just below that.

Code: [Select]
<table width="630" border="0" cellpadding="0" cellspacing="0">
 
<caption><strong><?php langtrans('Normal Rain')?></caption>
<tr>
<th style = "font-weight: lighter; color: Red;">This Month: &nbsp;<?php $mydate date('m'); $filename "rain".$mydate."mo.txt"; include($filename);?>&nbsp; in.</th>
<th style = "font-weight: lighter; color: Blue;">YTD: &nbsp;<?php $mydate date('m'); $filename "rain".$mydate."ytd.txt"; include($filename);?>&nbsp; in.</th>
</tr>

</table>

I then have files rain01mo.txt, rainmo02.txt, etc.  Those files have what "normal" rain for the current month is.

I then have rain01ytd.txt, rain02ytd.txt, etc in that have what the normal seasonal year to date should be at that point.

The above code gets the current month and then does the PHP include to show the data from each of the above txt files.  Simple and it gets the job done.  And I don't have to edit anything every month to show what the numbers should be.  It should just fetch it at load.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

 

anything