database not refreshing ...
Brought to you by:
iridium
From: Josh L. <jom...@gm...> - 2004-07-09 20:23:31
|
Hello All I have downloaded PHP Weather and am trying to use it as a part of my WordPress blog. I was able to get everything set up with a mysql db just fine and I am able to ouput the data like I want. The one nagging problem is the only way I can get new metar data is to manually re-create the tables through the config pages. My suspicion is there is one line of code or one variable that needs to be set to fix this, but I can' figure out what it is. I have pasted the code I am using below ... thanks in advance. If there is any further information I can provide, please let me know. josh seattle, wa <?php /* Begin PHP Weather Data Grab */ require('phpweather-2.2.2/phpweather.php'); require('phpweather-2.2.2/output/pw_images.php'); $weather = new phpweather(); /*set ICAO to KBFI (Boeing Field)*/ $weather->set_icao("KBFI"); $data = $weather->decode_metar(); /*update variables with metar data of interest*/ $temp_c = $data['temperature']['temp_c']; $temp_f = $data['temperature']['temp_f']; $wind_deg = $data['wind']['deg']; if ($wind_deg == "VRB") {$wind_deg = "Var";} if ($wind_deg >= 0 | $wind_deg <= 22) {$wind_deg = "North";} if ($wind_deg >= 23 | $wind_deg <= 68) {$wind_deg = "Northeast";} if ($wind_deg >= 69 | $wind_deg <= 112) {$wind_deg = "East";} if ($wind_deg >= 113 | $wind_deg <= 158) {$wind_deg = "Southeast";} if ($wind_deg >= 159 | $wind_deg <= 202) {$wind_deg = "South";} if ($wind_deg >= 203 | $wind_deg <= 248) {$wind_deg = "Southwest";} if ($wind_deg >= 249 | $wind_deg <= 292) {$wind_deg = "West";} if ($wind_deg >= 293 | $wind_deg <= 337) {$wind_deg = "Northwest";} if ($wind_deg >= 338 | $wind_deg <= 359) {$wind_deg = "North";} $wind_knots = $data['wind']['knots']; $precip_hr = $data['precipitation']['in']; if ($precip_hr == -1) {$precip_hr = "trace";} $barom_in = $data['altimeter']['inhg']; /*Get the METAR Report Time and Convert to PDT*/ $metarTime = $data['time']; $metarTime = $metarTime - 3600*7; $metarTime = gmdate("H:i", $metarTime); /* End PHP Weather Data Grab */ ?> ****The output for the weather report is as follows: <!-- Begin PHP Weather Output --> <?php if (!empty($temp_c)) { $output .= '<li id="temp">Temp: ' . $temp_f . " F (" . $temp_c . " C)</li>"; } if (!empty($wind_deg)) { $output .= '<li id="wind">Wind: ' . $wind_deg . " at " . $wind_knots . " knots</li>"; } if (!empty($barom_in)) { $output .= '<li id="barom">Barometer: ' . $barom_in . " in. of Hg</li>"; } if (!empty($precip_hr)) { $output .= '<li id="precip1hr">Precip (1hr): ' . $precip_hr . " in.</li>"; } if (empty($precip_hr)) { $output .= '<li id="precip1hr">Precip (1hr): 0 in.</li>'; } echo $output; ?> <!-- End PHP Weather Output --> |