cloudy

Author Topic: PHP Extraction of WD Avg/Ext HTM Files  (Read 43076 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 #120 on: March 15, 2008, 02:53:36 PM »
Henrik,
Your form might not work with this version because this version uses the form name "date" for the url get date input, your form is using the form name "report" for the url get date input.
To answer your question ...
The toggle is javascript and it is a new feature I just put in got this version of include-wxhistory.php, it required changes inside of the code section you posted and it requires some code in the html head section like this:

Code: [Select]
<!-- mchallis begin added for toggle 24 Hour Daily Chart images -->
<script type="text/javascript" language="JavaScript">
function toggleDisplay(imgID) {
   if(document.getElementById(imgID).style.display == "none" ) {
            document.getElementById(imgID).style.display = "";
   } else {
            document.getElementById(imgID).style.display = "none";
   }
}
</script>
<!-- mchallis end added for toggle 24 Hour Daily Chart images -->

</head>

To keep on topic in this thread... any more questions about AvgExtract.php outside of the Weather Display/PHP/AJAX Website Template Set I am happy to answer here:
http://www.weather-watch.com/smf/index.php/topic,28547.0.html

Hi MCHALLIS

Thanks for your reply and development of great scripts.

I have now added the code to my head section.

But im in doubt what to change in the avgextract.php script.

Could I ask you to send the code section of the .gif´s?

Code: [Select]
                    if ( $DAY != 0 ) {
                        echo "</table>\n";
                        echo '  <a target="_blank" href="' . $website . $yearnum . $monthnum . $DAY . '.gif">
                        Klik her for 24 timers graf for denne dag</a><br/>' . "\n";
                    }
                    preg_match("/Ekstremer for dag :(\d{1,2})\</",$value,$found);
                    $DAY = $found[1];
                    echo "<h3>Gennemsnit &amp; rekorder for dag " . intval($DAY) .
                        "</h3><table class='tbl'>";
                }
               
                // Check for Month Recap
               
                if ( strpos ($value, "Ekstremer for måned ") !== false ) {
                    echo "</table>\n";
                    echo '  <a target="_blank" href="' . $website . $yearnum . $monthnum . $DAY . '.gif">
                        Klik her for 24 timers graf for denne dag</a><br/> <br/>' . "\n";
                    echo "<h3>Gennemsnit &amp; rekorder for " . $month . " up to day " .
                        intval($DAY) . "</h3><table class='tbl'>";
                }

Best regards,

Henrik

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #121 on: March 15, 2008, 05:54:29 PM »
Try this:

Code: [Select]
                    if ( $DAY != 0 ) {
                        echo "</table>\n";

                          $this_img = $yearnum . $monthnum . $DAY;
                        # mchallis added if is_file check and image toggle feature
                        if (is_file("$website$this_img.gif")){
                         echo '
<p onclick="toggleDisplay(\'img_\' + '.$this_img.');">
Klik her for 24 timers graf for denne dag</p>
<img src="'. $website . $this_img .'.gif" id="img_'.$this_img .'" style="display: none" onclick="toggleDisplay(\'img_\' + '.$this_img.');" alt="24 hour Chart for Day '.$DAY.'" title="24 hour Chart for Day '.$DAY.'" />' . "\n";
                        } else {
                            echo "24 timers graf for denne dag is not available ($this_img.gif)<br/> <br/>" . "\n";
                        }

                    }
                    preg_match("/Ekstremer for dag :(\d{1,2})\</",$value,$found);
                    $DAY = $found[1];
                    echo "<h3>Gennemsnit &amp; rekorder for dag " . intval($DAY) .
                        "</h3><table class='tbl'>";
                }

               // Check for Month Recap

                if ( strpos ($value, "Ekstremer for måned ") !== false ) {
                    echo "</table>\n";

                        # mchallis added if is_file check
                        if (is_file("$website$this_img.gif")){
                         echo '
<p onclick="toggleDisplay(\'img_\' + '.$this_img.');">
Klik her for 24 timers graf for denne dag</p>
<img src="'. $website . $this_img .'.gif" id="img_'.$this_img .'" style="display: none" onclick="toggleDisplay(\'img_\' + '.$this_img.');" alt="24 hour Chart for Day '.$DAY.'" title="24 hour Chart for Day '.$DAY.'" />' . "\n";

                        } else {
                            echo "24 timers graf for denne dag is not available ($this_img.gif)<br/> <br/>" . "\n";
                        }
                    echo "<h3>Gennemsnit &amp; rekorder for " . $month . " up to day " .
                        intval($DAY) . "</h3><table class='tbl'>";
                }

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 #122 on: March 15, 2008, 08:04:37 PM »
Hi again

Thank for your reply and help - but unfortunately I cant get it working.

See this link: http://www.buskelundtoften.dk/vejret/rapporter.php

It says "24 timers graf for denne dag is not available (20080101.gif)"

What do you think can be the problem?

Best regards,

Henrik

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #123 on: March 15, 2008, 08:22:08 PM »
Hi again

Thank for your reply and help - but unfortunately I cant get it working.

See this link: http://www.buskelundtoften.dk/vejret/rapporter.php

It says "24 timers graf for denne dag is not available (20080101.gif)"

What do you think can be the problem?

Best regards,

Henrik

Henrik,

It is looking for th graph gif files in
http://www.buskelundtoften.dk/vejret/
but you have them in
http://www.buskelundtoften.dk/vejret/vejrdata/

You have the script and data in different directories so the script is not checking the if is_file correctly
What is your $website setting inside AvgExtract.php set to?







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 #124 on: March 15, 2008, 08:27:44 PM »
Hi again,

In the avgextract.php my website is set to:

$website = "http://www.buskelundtoften.dk/vejret/vejrdata/";

I have experimented by copying 20080301.gif to the www.buskelundtoften.dk/vejret folder - but it still dont work.

Hope you can figure something out.

Thank you very much for all your help

Best regards,

Henrik

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #125 on: March 15, 2008, 08:59:52 PM »
Henrik,

Try this setting for $website:
$website = "../../vejrdata/";

Also for the javascript toggle to work, make sure to put this in the head of the page dagligrapporter.php:

Code: [Select]
<!-- mchallis begin added for toggle 24 Hour Daily Chart images -->
<script type="text/javascript" language="JavaScript">
function toggleDisplay(imgID) {
   if(document.getElementById(imgID).style.display == "none" ) {
            document.getElementById(imgID).style.display = "";
   } else {
            document.getElementById(imgID).style.display = "none";
   }
}
</script>
<!-- mchallis end added for toggle 24 Hour Daily Chart images -->




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 #126 on: March 15, 2008, 09:16:04 PM »
Hi

Woo hoo that did the trick (for my Danish version).

Now I tried changing my English version located here:

www.buskelundtoften.dk/vejret/english/rapporter.php

Location of the dagligrapporter and avextract.php is here: www.buskelundtoften.dk/vejret/english/scripts/rapporter/

I changed the $website to:

$website = "../../../vejrdata/";

Hmm im just not good at this php coding  :D

Best regards,

Henrik


Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #127 on: March 15, 2008, 09:56:42 PM »
 
Just for testing

change this
echo "24 hour graph for this day is not available ($this_img.gif)<br/> <br/>" . "\n";

to this
echo "24 hour graph for this day is not available ($website$this_img.gif)<br/> <br/>" . "\n";

Then I can see why it is not working

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 #128 on: March 15, 2008, 10:00:25 PM »
Hi

Wow you are fast.

I have changed the line now.

Again thanks for all your help.

Best regards,

Henrik

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #129 on: March 15, 2008, 10:22:57 PM »
Henrik,

You can take that testing code out, the path is not the problem, the sate used for the input is the problem

The code you have is looking using a date like this [year][month][day]: 2008301 (notice the month you have is [3], it should be [03]
It is supposed to be like this: 20080301

The date is used to put together the image file name, but the missing a zero before the 3 makes it incorrect
2008301.gif instead of 20080301.gif

now the question remains why is the date for month missing a zero?

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 #130 on: March 16, 2008, 05:34:23 AM »
Hi Mike

Ups - I did a compare at the avgextract.php to my Danish and English version and there were some differences.

I corrected that, and now I have the script working both on my Danish and English site.

Thank you very much for your help on this - i apreciate it wery much.

Now - I only have one more question (sorry). How did you manage to make your rows light and dark? As far as I can see I have a left and right colomn.

All the other placed on my website, I use light and dark rows in my tables.

Thank you very much.

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 #131 on: March 16, 2008, 09:47:53 AM »
He uses a different CSS class for each row...

<tr class="column-dark">

<tr class="column-light">

 

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 #132 on: March 16, 2008, 10:52:03 AM »
Hi Kevin

Thanks for your reply.

To get the rows dark and light after eachother - there must have been changed in the avextract.php script?

Here is what I have in the script:
 
Code: [Select]
         echo "<tr><td class='left'>" .
                    $left .
                    "</td><td class='right'>" .
                    $right .
                    "</td></tr>\n";

Left and right - but how do I change that to dark and light - every second row?

Best regards,

Henrik

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: PHP Extraction of WD Avg/Ext HTM Files
« Reply #133 on: March 16, 2008, 02:30:32 PM »
Hi Kevin

Thanks for your reply.

To get the rows dark and light after eachother - there must have been changed in the avextract.php script?

Here is what I have in the script:
 
Code: [Select]
         echo "<tr><td class='left'>" .
                    $left .
                    "</td><td class='right'>" .
                    $right .
                    "</td></tr>\n";

Left and right - but how do I change that to dark and light - every second row?

Best regards,

Henrik

Henrik,

I have attached the version I made for ken's wd templates, I added many comments, you can compare if you like, but it does use 3 css classes from the wd template css table-top, column-light, and column-dark.



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 #134 on: March 16, 2008, 03:35:41 PM »
Hi Mike

Thanks for your reply.

Im not sure where you set the table-row-dark and light - do you specify that in Kevins avgextract.php?

Best regards,

Henrik

 

cumulus