Don't underestimate your own talent to learn.. you've done a great job with the script already!
I only started to learn PHP programming in March of this year.. I admit to being fairly expert with Perl (having done programming in it for over 10 years), but PHP syntax is just a bit different, so it has a learning curve too.
I learn best by seeing and analyzing code others have written, and for that start, I used the Tom's (carterlake) forecast script and Larry's (anole) sticker script. Feel free to bag and reuse any of my code from my scripts page (
http://saratoga-weather.org/scripts.php ) in your own quest
Now.. you're on the right track.. you already have a script that will do the scraping of the WU page for the data for 6 months.. all you have to add (I think) is a bit a parameter handling and a simple preg_replace to subsitute your page for the /weatherstation/WXDailyHistory.asp page.
Parameters can be handled like this (at the top of your page):
if (isset($_REQUEST['month')) { $mon = $_REQUEST['month']; }
if (isset($_REQUEST['year')) { $year = $_REQUEST['year']; }
if (isset($_REQUEST['day')) { $day = $_REQUEST['day']; }
//Set the Timezone
putenv("TZ=US/Pacific");
$now = getdate();
// set the day/month/year to current if not passed as parms
if(!$mon) { $mon = $now['mon'];}
if(!$year) { $year = $now['year'];}
if(!$day) { $day = $now['mday'];}
Then, where you're scraping the lines of the page, just include this statement to change the URL references:
$new = preg_replace('|/weatherstation/WXDailyHistory.asp|Uis','/station/wutable.php ',$line);
Since I can't see your PHP code, I've assumed the line your looking for is in $line and the replacement will be placed in $new.. you'll have to change the variable names to match the ones you're using to make it work, but I hope you get the picture.
This way, if /station/wutable.php is invoked without parameters, it will do the default of looking up using today's date. The internal links returned on the page will be rewritten to use your page, and the parameters will be passed through you and down to the URL for WeatherUnderground in your code.
Hope this helps...
Best regards,
Ken