Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2004
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to display current temperature

    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.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.

  • #3
    New Coder
    Join Date
    Nov 2004
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •