cloudy

Author Topic: PHP Extraction of WD Avg/Ext HTM Files  (Read 43055 times)

0 Members and 1 Guest are viewing this topic.

Offline jwwd

  • Posts: 3,545
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #15 on: December 23, 2007, 06:31:56 PM »
Hi again

I played a little with your script and got a bit further - here is the result:

http://www.buskelundtoften.dk/vejret/avgextract.php

Now my problem is - why are the rest of the values under the graph-link?

Still missing the totals in the bottom.

Best regards,

Henrik

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #16 on: December 23, 2007, 07:26:23 PM »
The format of your file is not consistent with what I tested against.  In the html files that I tested against, the last entry in the table for each day was Maximum Heat Index. 

You "sometimes" have an extra line called Regn i dag which is not in any of the charts that I tested against. The result is that the table is closed before that tag shows up.

I've updated the test2 script above to just ignore those lines completely.

http://www.tnetweather.com/scripts/wdavgext/sample2.php

http://www.tnetweather.com/scripts/wdavgext/sample2.txt

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline jwwd

  • Posts: 3,545
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #17 on: December 23, 2007, 08:20:34 PM »
Hi Kevin

Fantastic - its working. I think the "Regn i dag" line only occures when we have had rain. (It means "Rain today")

Just an small issue - I like to have my pages validated - and there seems to be a couple of errors:

Line 39: </FONT></B> shoud be removed
Line 501: </FONT></B> shoud be removed

Thank you very much for all your help and great scripts.

Best regards,

Henrik

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #18 on: December 23, 2007, 08:30:44 PM »
Originally they were stripped... Seems that I reintroduced them when I redid the script.

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #19 on: December 23, 2007, 08:34:31 PM »
Add the U in the line:

preg_match("/Daglig rapport for  (.*)\</",$value,$found);

preg_match("/Daglig rapport for  (.*)\</U",$value,$found);


Regex is greedy....

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline jwwd

  • Posts: 3,545
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #20 on: December 23, 2007, 08:47:24 PM »
Hi Kevin

Wow you are fast...................as always.

Its working now and now errors in W3 validation.

Thank you very much

Best regards,

Henrik

Offline Budgie

  • Martin
  • Global Moderator
  • Posts: 4,635
  • WML Station: WD00934 CWOP: CW7959
  • Isle of Lewis, Scotland
    • Hebrides-Weather
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #21 on: December 24, 2007, 12:09:38 AM »
Hi Kevin,

Thanks for the script, I had a little play with it and came up with this: http://www.hebrides-photos.com/weather/dec2007.php

One quesiton though, am I right in thinking that if I want to do this for each month then I'll need 12 avgextract.php files, one to point to each months .htm file?  Or is there a way to use one extract file and somehow tell it to look at, say September2007.htm, if 'September2007' that is in the title of the page?

Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #22 on: December 24, 2007, 12:47:24 AM »
Hi Kevin,

Thanks for the script, I had a little play with it and came up with this: http://www.hebrides-photos.com/weather/dec2007.php

One quesiton though, am I right in thinking that if I want to do this for each month then I'll need 12 avgextract.php files, one to point to each months .htm file?  Or is there a way to use one extract file and somehow tell it to look at, say September2007.htm, if 'September2007' that is in the title of the page?

Ideally, you would call the script with the date you want to output with a wrapper around it.

Then you are using the same script for all the data, not one script per page. 

You can then use one of the many examples of pull down boxes to select which month you are viewing.

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline Budgie

  • Martin
  • Global Moderator
  • Posts: 4,635
  • WML Station: WD00934 CWOP: CW7959
  • Isle of Lewis, Scotland
    • Hebrides-Weather
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #23 on: December 24, 2007, 12:53:38 AM »
I think I see what you're getting at, I already have the dropdown box at the top of the pages so that's sorted.
I'll have another paly with it tomorrow.  :wink:

Offline lulu836

  • Linda
  • Posts: 2,232
  • Louisiana
    • Luv Retirement
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #24 on: December 24, 2007, 02:50:42 AM »
Ideally, you would call the script with the date you want to output with a wrapper around it.

Then you are using the same script for all the data, not one script per page. 

with a wrapper around it.


Kevin........I know you've laid this out like a tray of freshly boiled crawfish but I have a question (or two):
1.  "you would call the script with the date you want to output"  no problem
2.  "with a wrapper around it"  basically understand
3.  "Then you are using the same script for all the data, not one script per page" 
I don't see how to do it without multiple instances of the script.  Since you (or at least I) can't execute PHP on my PC how does one save the resulting report )Jan, Feb, Mar, etc) to pin it down long enough to add a wrapper?
« Last Edit: December 24, 2007, 02:54:14 AM by lulu836 »


Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #25 on: December 24, 2007, 02:57:38 AM »
Does not your web host have PHP capabilities?

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline lulu836

  • Linda
  • Posts: 2,232
  • Louisiana
    • Luv Retirement
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #26 on: December 24, 2007, 03:01:14 AM »
Does not your web host have PHP capabilities?

Absolutely!!  Are you saying to save the generated report from the web page that's showing up in my web browser?  Color me confused :rofl:


Offline TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,859
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #27 on: December 24, 2007, 03:26:45 AM »
A wrapper is basically a page that calls the script within itself...

Like:

http://www.tnetweather.com/tws-raindetail.php

If you have not selected a "date", it uses the current date.  Otherwise it processes what the visitor asked for from the pull down menu.

There is no static anything, it is all dynamically generated when the user visits the page.

In the above example, the form...

<form  method="get" action="tws-raindetail.php" >
   <select name="date">
      <option value="2007"> 2007 </option>
      <option value="2006"> 2006 </option>
      <option value="2005"> 2005 </option>
      <option value="2004"> 2004 </option>   
   </select>
   <input type="submit" value="Go" />
</form>


Calls itself with the variable date in $_GET['date']

It is what makes PHP so powerful.

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline jwwd

  • Posts: 3,545
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #28 on: December 24, 2007, 06:42:47 AM »
Hi

Every end of month - I manually do:

1. Create a new month file (ie. November2007.php)
2. Insert climatedataout (ie. climatedataout112007.htm)
3. Insert the months graphs and pics (ie. 112007monthtodate.gif and more)
4. remove all formatting in avg/ext file (ie. November2007.htm) and insert in the file above

All of above is nearly possible now - I only need to change the avgextrac.php to automatic find the correct month.........would that be possible?

Here is an example of what I do every month:

http://www.buskelundtoften.dk/vejret/vejrdata/November2007.php

Best regards,

Henrik

Offline Budgie

  • Martin
  • Global Moderator
  • Posts: 4,635
  • WML Station: WD00934 CWOP: CW7959
  • Isle of Lewis, Scotland
    • Hebrides-Weather
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #29 on: December 24, 2007, 11:42:26 AM »
Kevin,

I think what's confusing all of us "PHP still in it's learning stages" people is that in the original script you've got the following code:
Code: [Select]
############################################################################

## THINGS TO CHANGE
// What website contains the data
$website = "http://www.hebrides-photos.com/weather/";

// Which Datafile to look at
$datafile = "December2007.htm";

# END OF CHANGES
#############################################################################

This points to a specific month/year file, that's why I was asking if you needed 12 avgextract.php files for each year.
How do you code it to call all the months of a year using this php file with the form code you put above? Also, where does that form code go, is it in the main page (Sample.php) or the avgextract.php file?

Sorry for the questions, it's just that PHP still confuses the hell out me. I really should sit down and go through a PHP tutoral at some point.  :wink: