<p><?php
date_default_timezone_set('Europe/Berlin');
if (isset($_POST['country'])) {
mysql_connect('localhost', 'root', 'wee123'); mysql_select_db('geolocation');
$re = mysql_query( "SELECT * FROM city where country='{$_POST['country']}' AND normalized_name='{$_POST['city']}'" );
$info = mysql_fetch_assoc( $re );
if ($info) {
$lat = $info['lat']; $lon = $info['lon'];
$info = date_sun_info(time(), $lat, $lon);
echo "Sunrise is at ", date(DateTime::RSS, $info['sunrise']), "\n";
echo "Sunset is at ", date(DateTime::RSS, $info['sunset']), "\n";
echo "Day length is ",
round(($info['sunset'] - $info['sunrise']) / 3600, 1), "hrs";
}
}
?></font>
<form method="post">
Country: <input name="country"/> City: <input name="city"/><br/>
<input type="submit" value="Check"/></form></p>
Output