Re: Syntax and adding images..
Brought to you by:
iridium
From: Martin G. <gim...@gi...> - 2002-03-27 08:53:18
|
"Donovan A. Huff" <do...@hu...> writes: > I have PHPWeather running but I am having a few issues getting the > precipitation to show up, I'd also like to add an image of the > current weather conditions like on the > http://www.moulton-udell.k12.ia.us/ site as described in the below > message. That should be easy now that we have images.inc. That's where the functions that deal with images are defined. The following code works: <?php include('./locale_en.inc'); include('./images.inc'); include('./phpweather.inc'); $metar =3D get_metar('EHEH'); $decoded_metar=3Dprocess_metar($metar); ?> <img src=3D"<? get_temp_image($decoded_metar) ?>" height=3D"50" width=3D"20= " border=3D"1"> <img src=3D"<? get_winddir_image($decoded_metar) ?>" height=3D"40" width=3D= "40" border=3D"1"> <img src=3D"<? get_sky_image($decoded_metar) ?>" height=3D"50" width=3D"80"= border=3D"1"> The code is taken from the file tables.php which is also in CVS in the phpweather-1.x directory. There you'll find a comprehensive test of the functions that deal with images. =20 > It seems like I'm making this process over complicated, but it is > working all except for the precipin and I believe that is due to the > wrong syntax. The problem is, that the precip_6h_in entry isn't a standard field in the METARs. So you cannot rely on it being available at all times, if at all. > Here is the current code I am using: >=20 > -- start -- >=20 > <?php > include('./weather/phpweather.inc'); > include('./weather/locale_en.inc'); > $metar =3D get_metar('KVCT'); > $data =3D process_metar($metar); > $temp_f =3D $data['temp_f']; > $windmph =3D $data['wind_miles_per_hour']; > $winddir =3D $data['wind_dir_text_short']; > $dewf =3D $data['dew_f']; > $humidity =3D $data['rel_humidity']; > $visibility =3D $data['visibility_miles']; > $precipin =3D $data['precip_6h_in']; Something like this would probably be better: if (empty($data['precip_6h_in'])) { $precipin =3D 'None'; } else { $precipin =3D $data['precip_6h_in']; } =20 =2D-=20 Martin Geisler My GnuPG Key: 0xF7F6B57B See my homepage at http://www.gimpster.com/ for: PHP Weather =3D> Shows the current weather on your webpage. PHP Shell =3D> A telnet-connection (almost :-) in a PHP page. |