Recent Changes - Search:

http://flashdental.com/viewtopic.php?m=2&tp=22554&l=175 Oli Diedrich http://fasnacht-glarus.ch/viewtopic.php?m=40&tp=19753&l=848 Kochs Tb http://fasnacht-glarus.ch/viewtopic.php?m=96&tp=19922&l=364 Kolkata City Maps http://flashdental.com/viewtopic.php?m=33&tp=22150&l=594 Old Garfunkel Mp3 http://flashdental.com/viewtopic.php?m=53&tp=22083&l=947 Old Confederate Jackets http://fischereiverband-glarus.ch/viewtopic.php?m=97&tp=70566&l=243 Pacific Capital Sarl http://fliegerstaffel11.ch/viewtopic.php?m=35&tp=27709&l=257 The Tenth Kingdom Cast http://flashdental.com/viewtopic.php?m=43&tp=22241&l=416 Old National Mortgage Services Irvine Ca http://fischereiverband-glarus.ch/viewtopic.php?m=70&tp=70336&l=944 P0402 Taurus Code http://fgv.li/viewtopic.php?m=91&tp=10793&l=342 Entertainment Alliance Ltd Mi http://fasnacht-glarus.ch/viewtopic.php?m=11&tp=20147&l=763 Korg Toneworks Px4a Reviews http://fasnacht-glarus.ch/viewtopic.php?m=83&tp=19533&l=284 Knit Pants http://fischereiverband-glarus.ch/viewtopic.php?m=59&tp=70290&l=946 P M July Redskins Defense Year http://fgv.li/viewtopic.php?m=92&tp=10959&l=784 Environmental Land Use http://flashdental.com/viewtopic.php?m=70&tp=21769&l=202 Oilfield Technical Society Tent Party http://fasnacht-glarus.ch/viewtopic.php?m=6&tp=20257&l=342 Kozoway Ken http://fasnacht-glarus.ch/viewtopic.php?m=66&tp=19585&l=886 Knock Out Liquids http://fasnacht-glarus.ch/viewtopic.php?m=72&tp=19549&l=504 Knitting Backgrounds http://fgv.li/viewtopic.php?m=82&tp=11023&l=643 Enzymes Immobilization http://fischereiverband-glarus.ch/viewtopic.php?m=57&tp=70543&l=453 Pacers Ind

Assignment2Gaby

What to wear

Online version: http://ernie.art.yale.edu/~gabrielatejada/weather/weatherfinal.php

Documentation book (pdf)

Source code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
        <title>Gaby's What to Wear</title>
       
        <style type="text/css">
        body {
                font-family: "Monaco";
                color: white;
                font-size: 12px;
                margin:10px;
                width:1200px;
               
        }
       
        .form {
                font-family: "Monaco";
                font-size: 12px;
                margin:0px;
                left:0px;
                top: 0px;
               
        }
       
        .date {
                font-family: "Monaco";
                font-size: 12px;
                margin:0px;
                left:0px;
                top: 0px;
                position:absolute;
                z-index:10;
                background-color:#000;
                color:#ffffff;
                width:240px;
                height=180px;
                padding 100px 100px 100px 100px;
               
               
               
        }
       
        .text {
                font-family: "Monaco";
                color: white;
                font-size: 12px;
                margin:-5px;
                left: 0px;
        }
       
        .caption {
                position:absolute;
                left:-10px;
                margin:0px;
                z-index:4;
                background-color:#000;
                color:#ffffff;
                width:280px;
                height=200px;
                padding 100px 100px 100px 100px;
        }
       
        .photo {
                position:relative;
                top:0px;
                left:-10px;
                z-index:0;
                white-space:nowrap;
        }
       
        </style>
       
</head>

<?php


//HELP/////////////////// i can'
t get the time to show as time it's as a counter  with this////////////////////

        $date = date('
F d, Y');
        $time = date('
g:i a');
       
        $hour = date("G");

// Display the <body> tag with a background that depends on the hour of the day

echo "<body background='
images/courtyard$hour.jpg'>";



// Display the date and time as text

echo "<span class='
date'>
                                <br />&nbsp;&nbsp;&nbsp;$date<br />&nbsp;&nbsp;&nbsp;$time<br /></span>";


//****************************** zip code ******************************
?>



        <form action="weatherfinal.php" method="get">
                <br><br><br />
                Enter your zip code: <br>
                <input type="text" name="zipcode"> <br> <br>
                <input class="form" type="submit" value="What should I wear?">
                <br> <br> <br><br>

<?php



// This function queries Flickr and then displays 5 resulting images, as a row, wtih a caption
//****************************** flickr code ******************************


function photo_row ($search_terms, $caption) {

        if (!$caption) $caption = $search_terms;

        $search_array = explode(",",$search_terms);
        foreach ($search_array as $search_term)
       
       
        {
                $flickr_key = '
76ad4379895ce2812719a4086b681dae';
                $flickr_url = "http://www.flickr.com/services/rest/?api_key=$flickr_key&method=flickr.photos.search&tags=$search_term&per_page=5";
                $dom = new DOMDocument();
                $dom->load($flickr_url);
                $photos = $dom->getElementsByTagName('
photo');
                               
                echo  "<span class='
caption'><br>&nbsp;&nbsp;&nbsp;
                $caption </span><br><span class='
photo'> ";     
               
                foreach($photos as $photo)
                        {
                        $id = $photo->getAttribute('
id');
                        $secret = $photo->getAttribute('
secret');
                        $server = $photo->getAttribute('
server');
                        $photo_to_display = '
http://static.flickr.com/' . $server . '/' . $id . '_' . $secret . '_m.jpg';
                        $photo_to_display = "<img src=" . $photo_to_display . ' width="240" height="180"';
                        echo $photo_to_display;
                        }
       
                echo
                "</span>
                <br /><br />
                <br /><br />
                <br /><br />"
;
               
                }
       
       
}

// only if zipcode is submitted, query yahoo for weather and show the results

//****************************** yahoo code ******************************

if (isset($_REQUEST["zipcode"]))
{

                $zipcode = $_REQUEST["zipcode"];
                $yahoo_url = "http://xml.weather.yahoo.com/forecastrss?p=$zipcode";
               
               
                $data = file_get_contents($yahoo_url);

                // reformat yahoo weather data
                $data = str_replace("yweather:", "", $data);
                $data = str_replace("geo:", "", $data);
               
                // load reformatted file into SimpleXML
                $xml_data = simplexml_load_string($data);
               
                $channel = $xml_data->channel;
               
                        $location = $channel->location;
                                $city = $location["city"]; // e.g. "New Haven"
               
                        $item = $channel->item;
                                $condition = $item->condition;
                                        $conditionText = $condition["text"]; // e.g. "Mostly Cloudy" (corresponds to code below)
                                        $conditionCode = $condition["code"]; // e.g. "26" (47 possibilities)
                                        $temp = $condition["temp"]; // e.g. 57
                                       
       

//****************************** display city row ******************************
                               
        $city_nospaces = str_replace(" ","",$city);
        photo_row($city_nospaces, "In $city");
       

       
//****************************** display temp row ******************************
       
        photo_row($temp, "the temperature is $temp&deg;");



//***************** display condition row (sometimes 2 rows) *******************

        $conditionLowerCase = strtolower($conditionText);
        $genericCaption = "conditions are $conditionLowerCase";

        if ($conditionCode == 0) {
                photo_row("tornado", "TORNADO!!! Go to your basement!" );
        }
        if ($conditionCode == 1) {
                photo_row("tropical storm", "There is a tropical storm going on.");
                photo_row("umbrella", "take an umbrella");
        }
        if ($conditionCode == 2) {
                photo_row("hurricane", "There is a hurricane outside.");
                photo_row("umbrella", "take an umbrella");
                }
        if ($conditionCode == 3) {
                photo_row("thunderstorms", "There are thunderstorms out,");
                photo_row("umbrella", "take an umbrella.");
                }
        if ($conditionCode == 4) {
                photo_row("thunderstorms", "There are thunderstorms out,");
                photo_row("umbrella", "take an umbrella.");
                }
        if ($conditionCode == 5) {
                photo_row("slush", "It's slushy outside,");
                photo_row("rainboots", "take boots.");
                }
        if ($conditionCode == 6) {
                photo_row("slush", "It's slushy outside,");
                photo_row("rainboots", "take boots.");
                }
        if ($conditionCode == 7) {
                photo_row("slush", "It's slushy outside,");
                photo_row("rainboots", "take boots.");
                }
        if ($conditionCode == 8) {
                photo_row("drizzle", "It's drizzling outside,");
                photo_row("umbrella", "take an umbrella.");
                }
        if ($conditionCode == 9) {
                photo_row("drizzle", "It's drizzling outside,");
                photo_row("umbrella", "take an umbrella.");
                }
        if ($conditionCode == 10) {
                photo_row("freezingrain", "Freezing rain is falling down,");
                photo_row("umbrella", "take an umbrella.");
                }
        if ($conditionCode == 11) {
                photo_row("showers", "It is pouring out!");
                photo_row("umbrella", "Take an umbrella.");
                }
        if ($conditionCode == 12) {
                photo_row("showers", "It is pouring out!");
                photo_row("umbrella", "Take an umbrella.");
                }
        if ($conditionCode == 13) {
                photo_row("flurries", "Flurries are falling,");
                photo_row("umbrella", "take an umbrella.");
                }
        if ($conditionCode == 14) {
                photo_row("snowshowers", "Outside it is snowshowering.");
                }
        if ($conditionCode == 15) {
                photo_row("blowingsnow", "The snow is blowing!");
                }
        if ($conditionCode == 16) {
                photo_row("snow", "Snowflakes! It is snowing out!");
                }
        if ($conditionCode == 17) {
                photo_row("hail", "There is hail out!");
                }
        if ($conditionCode == 18) {
                photo_row("sleet", "There is sleet out!");
                photo_row("umbrella", "Take an umbrella.");
                }
        if ($conditionCode == 19) {
                photo_row("dust", "It is dusty out.");
                }
        if ($conditionCode == 20) {
                photo_row("foggy", "It is foggy out. Watch out!");
                }
        if ($conditionCode == 21) {
                photo_row("haze", "It is hazy out. Watch out!");
                }
        if ($conditionCode == 22) {
                photo_row("smoky", "It is smokey out.");
                }
        if ($conditionCode == 23) {
                photo_row("blustery", "It is blustery out.");
        }
        if ($conditionCode == 24) {
                photo_row("windy", "It is windy out.");
        }
        if ($conditionCode == 25) {
                photo_row("cold", "It is cold cold cold out.");
        }
        if ($conditionCode == 26) {
                photo_row("cloudy", "It is cloudy outside.");
        }
        if ($conditionCode == 27) {
                photo_row("cloudy", "It is cloudy outside.");
        }
        if ($conditionCode == 28) {
                photo_row("cloudy", "It is cloudy outside.");
        }
        if ($conditionCode == 29) {
                photo_row("cloudy", "It is cloudy outside.");
        }
        if ($conditionCode == 30) {
                photo_row("cloudy", "It is cloudy outside.");
        }
        if ($conditionCode == 31) {
                photo_row("night", $genericCaption);
        }
        if ($conditionCode == 32) {
                photo_row("sunny", "It is sunny outside.");
                photo_row("sunglasses", "take sunglasses");
        }
        if ($conditionCode == 33) {
                photo_row("fair", "It is nice outside.");
        }
        if ($conditionCode == 34) {
                photo_row("fair", "It is nice outside.");
        }
        if ($conditionCode == 35) {
                photo_row("hail", "There is hail out!");
        }
        if ($conditionCode == 36) {
                photo_row("hot", "It is hot hot hot!");
        }
        if ($conditionCode == 37) {
                photo_row("thunderstorms", "There are thunderstorms out,");
                photo_row("umbrella", "take an umbrella.");
        }
        if ($conditionCode == 38) {
                photo_row("thunderstorms", "There are thunderstorms out,");
                photo_row("umbrella", "take an umbrella.");
        }
        if ($conditionCode == 39) {
                photo_row("thunderstorms", "There are thunderstorms out,");
                photo_row("umbrella", "take an umbrella.");
        }
        if ($conditionCode == 40) {
                photo_row("thunderstorms", "It is pouring out,");
                photo_row("umbrella", "take an umbrella.");
        }
        if ($conditionCode == 41) {
                photo_row("heavysnow", "It is snowing hard!");
        }
        if ($conditionCode == 42) {
                photo_row("snow", "It is snowing!");
        }
        if ($conditionCode == 43) {
                photo_row("heavysnow", "It is snowing hard!");
        }
        if ($conditionCode == 44) {
                photo_row("partlycloudy", "It is partly cloudy out.");
        }
        if ($conditionCode == 45) {
                photo_row("thunderstorms", "There are thunderstorms out,");
                photo_row("umbrella", "take an umbrella.");
        }
        if ($conditionCode == 46) {
                photo_row("snow", "It is snowing!");
        }
        if ($conditionCode == 47) {
                photo_row("thunderstorms", "There are thunderstorms out,");
                photo_row("umbrella", "take an umbrella.");
        }




}



//***************** display temp range rowws (between 1 and 13 rows) *******************

        if ($temp >= 100) {
                photo_row("naked", "It is hot!!Go out naked!!!");
        }
        if (($temp >= 90) and ($temp < 100)) {
                photo_row("underwear", "Wear only your underwear.");
        }
        if (($temp >= 80) and ($temp < 90)) {
                photo_row("shorts", "Wear shorts,");
                photo_row("tanktop", "and a tank top.");
        }
        if (($temp >= 70) and ($temp < 80)) {
                photo_row("shorts", "Wear shorts,");
                photo_row("tanktop", "a tank top,");
                photo_row("flipflops", "and some flip flops.");
        }
        if (($temp >= 60) and ($temp < 70)) {
                photo_row("jeans", "You should wear jeans,");
                photo_row("shirt", "a shirt,");
                photo_row("sweater", "a sweater,");
                photo_row("socks", "and some socks.");
        }
        if (($temp >= 50) and ($temp < 60)) {
                photo_row("jeans", "You should wear jeans,");
                photo_row("shirt", "a shirt,");
                photo_row("sweater", "a warm sweater,");
                photo_row("boots", "a pair of boots,");
                photo_row("scarf", "and a nice scarf!");
        }
        if (($temp >= 40) and ($temp < 50)) {
                photo_row("jeans", "It is getting cold! Wear jeans,");
                photo_row("shirt", "a shirt,");
                photo_row("sweater", "a warm sweater,");
                photo_row("boots", "a pair of boots,");
                photo_row("scarf", "a warm scarf,");
                photo_row("gloves", "some gloves,");
                photo_row("jacket", "a jacket");
                photo_row("hat", "and a big hat!");
        }
        if (($temp >= 30) and ($temp < 40)) {
                photo_row("jeans", "Getting chilly!! Wear some jeans,");
                photo_row("shirt", "a shirt,");
                photo_row("sweater", "a warm sweater,");
                photo_row("boots", "a pair of boots,");
                photo_row("scarf", "a warm scarf,");
                photo_row("gloves", "take your gloves,");
                photo_row("coat", "a warm coat,");
                photo_row("hat", "a hat,");
                photo_row("earmuffs", "and take your ear muffs.");
        }
        if (($temp >= 20) and ($temp < 30)) {
                photo_row("jeans", "Bbbrrrr!!! Wear jeans,");
                photo_row("shirt", "a shirt,");
                photo_row("sweater", "a warm sweater,");
                photo_row("boots", "a pair of boots,");
                photo_row("scarf", "a warm scarf,");
                photo_row("gloves", "your gloves,");
                photo_row("coat", "a warm coat,");
                photo_row("hat", "a warm hat,");
                photo_row("earmuffs", "your ear muffs.");
                photo_row("vest", "and a vest.");
        }
        if (($temp >= 10) and ($temp < 20)) {
                photo_row("jeans", "It is freeeezing! Wear jeans,");
                photo_row("shirt", "a shirt,");
                photo_row("sweater", "your warmest sweater,");
                photo_row("boots", "a pair of warm boots,");
                photo_row("scarf", "your warmest scarf,");
                photo_row("gloves", "your gloves,");
                photo_row("coat", "your warmest coat,");
                photo_row("hat", "your warmest hat,");
                photo_row("earmuffs", "your ear muffs.");
                photo_row("vest", "your warmest vest,");
                photo_row("longunderwear", "and your long jhons!");
       
       
        }
       
        if (($temp >= 1) and ($temp < 10)) {
                photo_row("jeans", "It is freeeezing! Wear jeans,");
                photo_row("shirt", "a shirt,");
                photo_row("sweater", "your warmest sweater,");
                photo_row("boots", "a pair of warm boots,");
                photo_row("scarf", "your warmest scarf,");
                photo_row("gloves", "your gloves,");
                photo_row("coat", "your warmest coat,");
                photo_row("hat", "your warmest hat,");
                photo_row("earmuffs", "your ear muffs.");
                photo_row("vest", "your warmest vest,");
                photo_row("longunderwear", "long jhons,");
                photo_row("parka", "and big warm parka!");
        }
       
       
//      if (($temp >= -10) and ($temp < 0)) {
//            photo_row("jeans", "It is freeeezing! Wear jeans,");
//            photo_row("shirt", "a shirt,");
//            photo_row("sweater", "your warmest sweater,");
//            photo_row("boots", "a pair of warm boots,");
//            photo_row("scarf", "your warmest scarf,");
//            photo_row("gloves", "your gloves,");
//            photo_row("coat", "your warmest coat,");
//            photo_row("hat", "your warmest hat,");
//            photo_row("earmuffs", "your ear muffs.");
//            photo_row("vest", "your warmest vest,");
//            photo_row("longunderwear", "long jhons,");
//            photo_row("parka", "a big warm parka,");
//            photo_row("bodywarmer", "and a body warmer!");
               
//}
       
//            if (($temp >= -20) and ($temp < -10)) {
//            photo_row("jeans", "It is freeeezing! Wear jeans,");
//            photo_row("shirt", "a shirt,");
//            photo_row("sweater", "your warmest sweater,");
//            photo_row("boots", "a pair of warm boots,");
//            photo_row("scarf", "your warmest scarf,");
//            photo_row("gloves", "your gloves,");
//            photo_row("coat", "your warmest coat,");
//            photo_row("hat", "your warmest hat,");
//            photo_row("earmuffs", "your ear muffs.");
//            photo_row("vest", "your warmest vest,");
//            photo_row("longunderwear", "long jhons,");
//            photo_row("parka", "a big warm parka,");
//            photo_row("bodywarmer", "a body warmer,");
//            photo_row("duvet ", "and bring along your duvet!");      
//      }
       
       
//            if (($temp >= -21)  {
//            photo_row("bed", "It is too cold! Stay home in bed!");
       
               
//      }


?>



</body>
</html>
 

Edit - History - Print - Recent Changes - Search
Page last modified on April 26, 2006, at 01:27 AM