Location: PHPKode > scripts > Free PHP Ajax Yahoo Weather API > free-php-ajax-yahoo-weather-api/ajax.php
<?php
/*
This script was downloaded at:
LightPHPScripts.com
Please support us by visiting
out website and letting people
know of it.
Produced under: LGPL
*/

// Get options
include('configs.php');


if($USE_DATA){
	// Include database
	include_once('database.php');
} else {
	// Include state List
	include_once('state_list.php');
}

// Are we showing zipcode?
if($zip_code != NULL){	
	// Get weather info
	$f = fopen('http://weather.yahooapis.com/forecastrss?p='.$state_code,'r');
	while($t = fread($f,102465)){ $content .= $t; }
	fclose($f);
	preg_match('/<img src="(.*)"\/>/Usm',$content,$results); $image = $results[1];
	preg_match('/Current Conditions:<\/b><br \/>(.*)<BR \/>/Uism',$content,$results); $cur_conditions = $results[1];
	preg_match('/Forecast:<\/b><BR \/>(.*)<br \/>/ism',$content,$results); $forecast = $results[1];
	unset($content);
?>
	<table width="100%" border="1" cellpadding="3" cellspacing="2" bordercolor="#990000">
        <tr bordercolor="#990000">
          <td bgcolor="#FFE6E6"><div align="center"><strong>Weather for
            <?=$cityname;?>
            ,
            <?=$state_name;?>
                    <?=$zip_code;?>
            : </strong></div></td>
        </tr>
        <tr>
          <td><img src="<?=$image;?>"/><br/>
            <br/>
            <strong>Current Conditions:</strong><br/>
            <?=$cur_conditions;?>
            <br/>
            <br/>
            <strong>Forecast:</strong><br/>
            <?=$forecast;?></td>
        </tr>
      </table>
	  
<?php
return;
} 

// Are we showing states
if($_GET['state'] != NULL){
?>
<select name="zipcode2" id="zipcode2" onChange="doAjax('2');">
<option value=""></option>
<?=$city_list_form;?>
</select>
<?php }

?>
Return current item: Free PHP Ajax Yahoo Weather API