All pastes #2084079 Raw Edit

Miscellany

public text v1 · immutable
#2084079 ·published 2011-09-28 19:01 UTC
rendered paste body
<?php

$con = mysql_connect("localhost","weather","weather");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}
mysql_select_db("weather", $con);


if (!empty($_POST['CITY'])) {

	$CITY = $_POST['CITY'];
	$result = mysql_query("SELECT CITY,LONGITUDE,LATITUDE FROM weather WHERE CITY = '".mysql_real_escape_string($CITY)."' LIMIT 1") or die(mysql_error());
	$row = mysql_fetch_assoc($result);
	$myLong = $row['LONGITUDE'];
	$myLat = $row['LATITUDE'];

	include("get-UV-forecast-inc.php");	
	print "UV Forecast for $UVfcstDate[0] is $UVfcstUVI[0] <br/><br/><small>($requiredNote)</small>\n";
	mysql_close($con);
} else {
?>

	<form method="POST" action="<?=$_SERVER['PHP_SELF']?>">
	<select name="CITY">
	<?php
	$result = mysql_query("SELECT * FROM weather") or die(mysql_error());
	while ($row = mysql_fetch_assoc($result)) {

		$CITY = $row['CITY'];
		echo "<option value='$CITY'>$CITY</option>";

	}
	?>
	</select>
	<input name="Submit" type="submit" value="Submit" />
	</form>

<?php
}
?>