Well, that's kinda a tall order since I don't know how much PHP you're already familiar with. How about we approach
"To be functional, you would need to have WeatherCat process and upload a template page with the STMONTHLY$ tag in it, and write a PHP script to slice/dice the output as you desire."
with some code examples on how the problem might be solved (I find I learn best by seeing the code
The basic structure for solving a 'get some data and present it' problem with PHP can be divided into three basic parts:
1) get some raw-data from somewhere
2) parse the data into PHP variables -- this can be the tricky part
3) use PHP echo/print statements with HTML to display the desired data on the page.
Remember that a PHP page is just an HTML page with some embedded PHP code in it, and everything between a starting <?php and the next ending ?> is treated as PHP code by the interpreter and is output as a 'null'/non-existent in the resulting HTML (unless the PHP code uses print/echo statements to cause output to appear).
For (1), 'get some raw-data', here's where the webtags for WeatherCat come in. A simple statement like
<?php $rawdata = 'STMONTHLY$';
?>
should (when the page is processed and uploaded to your website), cause $rawdata to have contents like
Saratoga-weather.org
Day TempHi TempLo TempAv HeatHi HeatLo HeatAv ChillHi ChillLo ChillAv DewPHi DewPLo DewPAv HumHi HumLo HumAv PresHi PresLo PresAv R/hHi R/hLo R/hAv Rain AvWsHi AvWsLo AvWsAv GustHi GustLo GustAv WDir WRun SolHi SolLo SolAv UVHi UVLo UVAv
1 94.7 52.8 72.8 91.6 52.8 72.6 94.7 52.8 72.8 56.3 45.2 51.5 86 20 54 29.94 29.78 29.85 0.00 0.00 0.00 0.00 6 0 1 14 0 2 221 22.4 948 0 336 10.5 0.0 2.7
2 85.9 53.5 66.9 84.6 53.5 67.2 85.9 53.5 66.9 57.7 48.6 53.2 89 35 64 29.79 29.68 29.74 0.00 0.00 0.00 0.00 4 0 1 11 0 2 128 18.0 933 0 326 9.7 0.0 2.5
3 83.4 49.4 65.2 82.5 49.4 65.9 83.4 49.4 65.2 58.4 46.0 52.5 91 37 67 29.86 29.72 29.78 0.00 0.00 0.00 0.00 4 0 1 11 0 2 88 20.1 922 0 321 8.9 0.0 2.3
4 77.7 53.6 64.3 79.0 53.6 65.2 77.7 53.6 64.3 58.2 50.0 53.8 91 48 71 29.97 29.85 29.90 0.00 0.00 0.00 0.00 5 0 1 13 0 3 129 26.8 897 0 309 9.1 0.0 2.4
5 74.6 56.5 63.9 77.5 56.5 65.3 74.6 56.5 63.9 57.0 51.4 53.6 85 51 71 29.99 29.92 29.96 0.00 0.00 0.00 0.00 4 0 1 13 0 3 108 27.2 908 0 310 9.8 0.0 2.6
6 81.4 55.9 66.2 81.6 55.9 66.8 81.4 55.9 66.2 58.9 50.8 54.4 85 44 68 29.96 29.85 29.91 0.00 0.00 0.00 0.00 4 0 1 12 0 3 121 19.9 906 0 297 10.3 0.0 2.6
7 93.6 56.5 73.7 94.3 56.5 74.1 93.6 56.5 73.7 62.5 52.4 57.1 87 33 60 29.89 29.73 29.81 0.00 0.00 0.00 0.00 3 0 0 10 0 2 184 11.5 926 0 325 10.3 0.0 2.7
8 76.7 58.9 65.1 78.5 58.9 65.6 76.7 58.9 65.1 60.2 50.3 54.9 84 55 70 29.75 29.71 29.73 0.00 0.00 0.00 0.00 0 0 0 3 0 0 295 0.0 560 0 157 3.4 0.0 0.7
Monthly High 94.7 58.9 73.7 94.3 58.9 74.1 94.7 58.9 73.7 62.5 52.4 57.1 91 55 71 29.99 29.92 29.96 0.00 0.00 0.00 0.00 6 0 1 14 0 3 - 27.2 948 0 336 10.5 0.0 2.7
Monthly Low 74.6 49.4 63.9 77.5 49.4 65.2 74.6 49.4 63.9 56.3 45.2 51.5 84 20 54 29.75 29.68 29.73 0.00 0.00 0.00 0.00 0 0 0 3 0 0 - 0.0 560 0 157 3.4 0.0 0.7
Monthly Average 83.5 54.6 67.3 83.7 54.6 67.8 83.5 54.6 67.3 58.7 49.3 53.9 87 40 66 29.89 29.78 29.83 0.00 0.00 0.00 0.00 4 0 1 11 0 2 159 18.2 875 0 298 9.0 0.0 2.3
Monthly Total
which is ripe for parsing.
(2) Let's slice and dice that data into convenient arrays by using something like
<?php $datalines = explode("\n",$rawdata); ?>
which puts those lines into an array $datalines based on the new-line character.
Then a
<?php
foreach ($datalines as $i => $line) { ... } ?>
can walk through each separate $line and some processing can be done like
<?php
$Rain = array(); // blank storage area for rain values
foreach ($datalines as $i =>$line ) {
preg_split("|\s+|",$line,$vals); // carve up the lines into values by splitting on whitespace
if(isset($vals[0]) and preg_match('|^\d+$|',$vals[0]) ) {
// got one of the value lines we're looking for -- save it away in the $Rain array
$Rain[$vals[0]] = $vals[22]; // the rain total field is number 22 (counting from 0) in the record
}
}
// now the $Rain[] array is ordered by day with the value of rain for that day as the contents of that array entry.
?>
What we did above was walk through each line (with the foreach), use preg_split to put the individual values on that line into an array $vals, see if the first $vals is numeric (meaning a day-of-the-month) and if so, collecting the data we wanted for later use.
Now in part 3 (present the data) you can do something simple like
<?php
foreach ($Rain as $day => $amount) {
print "Day: $day had $amount of rain.<br/>\n";
}
?>
to print the list.
Hopefully this will give you enough fodder to start your PHP exploration. Pretty much all of my 'get-data-and-format' scripts follow this general structure so using my scripts as examples is also recommended as ways of doing stuff with PHP.
Best regards,
Ken