Recent Changes - Search:

aohavkbs, http://www.tomshw.it/forum/members/buy-glucophage.html glucophage conveniente, tndgogaw, http://www.tomshw.it/forum/members/comprar-zyprexa.html zyprexa conveniente, vtyyhpgn, http://www.tomshw.it/forum/members/comprar-desyrel.html desyrel conveniente, fxjgwxxe, http://www.tomshw.it/forum/members/comprar-cytotec.html cytotec prezzo ridotto, sazxpbxj,

Assignment2Thom

New Orleans

Online version: http://ernie.art.yale.edu/~networks/otherusers/thom/weather3.php

Source code:

<html>
<head>
<title>The City of New Orleans</title>
<style>
body {font: 120px sans-serif; color:#f05;}
</style>
</head>
<body>
<?php

//Create Array, Fill in applicant numbers as of 01-02-06

$cities = array();

$cities['70112'] = array('applicants'=>364958);
$cities['77002'] = array('applicants'=>317809);
$cities['70801'] = array('applicants'=>187738);
$cities['77701'] = array('applicants'=>132448);
$cities['39501'] = array('applicants'=>98961);
$cities['36602'] = array('applicants'=>90018);
$cities['39201'] = array('applicants'=>84693);
$cities['70601'] = array('applicants'=>71245);
$cities['70360'] = array('applicants'=>69781);
$cities['39563'] = array('applicants'=>57199);

$cities['75201'] = array('applicants'=>55279);
$cities['39401'] = array('applicants'=>45971);
$cities['70501'] = array('applicants'=>40585);
$cities['30303'] = array('applicants'=>32786);
$cities['71301'] = array('applicants'=>13127);
$cities['71101'] = array('applicants'=>12716);
$cities['78701'] = array('applicants'=>12471);
$cities['78201'] = array('applicants'=>11684);
$cities['38103'] = array('applicants'=>9744);
$cities['90001'] = array('applicants'=>7203);

$cities['35203'] = array('applicants'=>5967);
$cities['71201'] = array('applicants'=>5895);
$cities['60601'] = array('applicants'=>5732);
$cities['10001'] = array('applicants'=>5608);
$cities['32501'] = array('applicants'=>5205);




foreach($cities as $key=>$city) {
       
        //Read weather and location data for each zip code and store in array

        // First just load the file as straight data. We need to alter it before we can begin.
        $xmlstring = "http://xml.weather.yahoo.com/forecastrss?p=" . $key;
        $xmlContents = file_get_contents($xmlstring);
        $xmlContents = str_replace("yweather:", "", $xmlContents);
        $xmlContents = str_replace("geo:", "", $xmlContents);

        // Now load the string into SimpleXML
        $xml = simplexml_load_string($xmlContents);

        // <channel> node contains some of the info
        $channel = $xml->channel;

        // Location name: only the attributes are meaningful
        $location = $channel->location;
        $city['city'] = $location["city"]; // e.g. "New Haven"
        $city['region'] = $location["region"]; // e.g. "CT"
        $city['country'] = $location["country"]; // e.g. "US"

        // Atmosphere data: only the attributes are meaningful
        $atmosphere = $channel->atmosphere;
        $city['humidity'] = $atmosphere["humidity"]; // e.g. "93"
        $city['visibility'] = $atmosphere["visibility"]; // e.g. "1609"
        $city['pressure'] = $atmosphere["pressure"]; // e.g. "30.12"
        $city['rising'] = $atmosphere["rising"]; // e.g. "0"


        // <item> node is within the <channel> node, contains additional info
        $item = $channel->item;
        $city['lat'] = $item->lat; // Latitude, e.g. "37.39"
        $city['long'] = $item->long; // Longitude, e.g. "122.03"

        // Condition data: only the attributes are meaningful
        $condition = $item->condition;
        $city['conditionText'] = $condition["text"]; // e.g. "Mostly Cloudy" (corresponds to code below)
        $city['conditionCode'] = $condition["code"]; // e.g. "26" (47 possibilities)
        $city['temp'] = $condition["temp"]; // e.g. 57
        //$city['date'] = $condition["date"]; // e.g. Tue, 29 Nov 2005 3:56 pm PST

        //$description = $item->description;
        //$city['description'] = $description;
       
        // Begin Layout
        echo "<div style='text-align:left; background:transparent; position:absolute;";
       
        $textsize = round(100*($city['applicants']/364958));
        if ($textsize < 8) {$textsize=8;}
        echo "font-size:" . $textsize . "%;";

        $leftposround(50*($city['humidity']/51));
        echo "left:" . $leftpos . "%;";
        $toppos = round(50*($city['temp']/73));
        echo "top:" . $toppos . "%;";
        echo "'>";
        echo "<img src='http://us.i1.yimg.com/us.yimg.com/i/us/we/52/" . $city['conditionCode'] . ".gif' />";
        echo $city['city'] . ", " . $city['region'];
       
        echo '</div>';
}

echo '<br />';

?>

</body>
</html>

Edit - History - Print - Recent Changes - Search
Page last modified on April 23, 2006, at 05:29 PM