...

View Full Version : How to display current temperature



johnnybananas
09-07-2005, 06:30 AM
Does anyone know how to display the current temperature of a given city. I was told a server side script like php is needed. Any assistance on how to go about it would be great.

Here is a link to a website that has this script in place...

http://www.lasplash.com/

Slowly scroll down to the bottom and on your right-hand side you will see the current temperature reading.

Fou-Lu
09-07-2005, 03:33 PM
Hi JohnnyBananas,
First, this depends on how in depth you want this to be. With this site, it states a specific city. However, if your looking for a way to display a viewer's city, that will be a little trickier. This is because its tough to track down what city a user is located in, even by using an IP method. Unfortunatly, I cannot help you too much with this.

Now, quite a number of forcasting stations or general national weather networks will be able to provide you with this information. Php cannot determine the weather of course. So you will want to visit a larger, preferably more national weather website and search for an RSS or XML feed. This can provide you with the weather details, in a format php can understand -> XML. You can process this data in numerous ways, I do recommend you use a server side XML processor no matter what choice you take, as XSL is not supported by all browsers (but can be converted from XML:XSL to HTML using php).

First find a site that can provide you with this data in XML or an RSS feed, then get back to us here, we can help you with how to impliment this data into your own website.

johnnybananas
09-08-2005, 08:19 AM
Thanks for offering your assistance Fou-Lu. I found the following site with RSS and XML feeds.

http://weather.gov/data/current_obs/seek.php?state=ca

Specifically, I want to include the Los Angeles Downtown/Usc (KCQT) area.
Here's the link with the code listed for that feed....

http://weather.gov/data/current_obs/KCQT.xml

Can you please show me how to implement this script?

Fou-Lu
09-09-2005, 03:09 AM
Sure, my recommendation would be to impliment an XSL stylesheet, and process this server side if available. Php 5.x impliments XSL in its core, however 4.x requires additional libraries for these process', namely sablot.dll, expat.dll and iconv.dll (4.2.1+). These are all included within the 4.1+ php's extensions, and chances are they are configured on your host server.

If you are unsure of how to create XSL stylesheets, please provide me with the HTML markup and general look of the weather you would like. Just create one the way you want it to look, implimenting some weather data as well.

As well, please tell me what version of php you are using so that this can be implimented.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum