Location: PHPKode > scripts > Free Yahoo Weather API Fetcher > free-yahoo-weather-api-fetcher/database.php
<?php
/************* Weather *****************************/
/*
Released by AwesomePHP.com, under the GPL License, a
copy of it should be attached to the zip file, or
you can view it on http://AwesomePHP.com/gpl.txt
*/
/************* Weather *****************************/

$DB_USER =  "root";
$DB_PASSWORD = "master";
$DB_HOST = "localhost";
$dbc = mysql_connect ($DB_HOST, $DB_USER, $DB_PASSWORD) or $error = mysql_error();
mysql_select_db("bostwick") or $error = mysql_error();
mysql_query("SET NAMES `utf8`");

// If zipcode exist, assign statename/code
if($zip_code != NULL && is_numeric($zip_code)){
	$get_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `city_list` WHERE `zip_code`='$zip_code'"));
	$_GET['state'] = $get_info['state_name'];
	$cityname = $get_info['city_name'];
	$state_code = $get_info['state_code'];
}

// Get ready state list
$get_list = mysql_query("SELECT `state_name` FROM `city_list` GROUP BY `state_name` ASC");
while($each = mysql_fetch_assoc($get_list)){
	if($_GET['state'] == $each['state_name']){$sel= ' selected';}else{$sel=NULL;}
	$state_list_form .= '<option value="'.$each['state_name'].'"'.$sel.'>'.$each['state_name'].'</option>';
}

// Print city list
if($_GET['state'] != NULL){
	$get_city = mysql_query("SELECT * FROM `city_list` WHERE `state_name`='$_GET[state]'");
	while($each = mysql_fetch_assoc($get_city)){
		if($zip_code == $each['zip_code']){
		$sel= ' selected'; 
		}else{$sel=NULL;}
		$city_list_form .= '<option value="'.$each['zip_code'].'"'.$sel.'>'.$each['city_name'].' ['.$each['zip_code'].']</option>';
	}
}

@mysql_close($dbc);
@mysql_close();

?>
Return current item: Free Yahoo Weather API Fetcher