Location: PHPKode > projects > Worldweather > worldweather/web/index.php
<?
require ("conf/config.php");

$link = @mysql_pconnect ($default->db_server,$default->db_user,$default->db_pass)
  or exit ();
mysql_select_db ($default->db_database)
  or exit ();
if (empty($country)) {
  $country = 'Netherlands';
}
?>
<head>
<title>World Weather by fieldworx</title>
</head>
<body>
<center>
<CENTER>fieldworx.homeip.net<BR>World weather based on METAR information provided by noaa.gov</CENTER><BR>
<form action="index.php" method="post">
Country : <select name="country" onChange="this.form.submit()">
<?
$result = mysql_query (" SELECT DISTINCT metarstations.country FROM countries,metarstations,stations WHERE (countries.name=metarstations.country) AND (metarstations.ICAO=stations.ICAO) ORDER BY metarstations.country")
  or exit ();
while ($row = mysql_fetch_row ($result))
{
   if ($row[0] == $country) {
    echo "<option selected value=\"$row[0]\">$row[0]</option>\n";
  } else {
    echo "<option value=\"$row[0]\">$row[0]</option>\n";
  }
}
?>
</select>
<BR> 
<form action="index.php" method="post">
Station : <select name="int_id" onChange="this.form.submit()">
<?
$result = mysql_query ("SELECT DISTINCT stations.ICAO,metarstations.placename FROM metarstations,stations WHERE (metarstations.country='$country') AND (metarstations.ICAO=stations.ICAO) ORDER BY metarstations.placename")
  or exit ();
$found="";
$firstval="";
$graphcomment="";
while ($row = mysql_fetch_row ($result))
{
   if (empty($firstval)) {
     $firstval=$row[0];
     $graphcomment=urlencode($row[1]);
   } 
   if ($row[0] == $int_id) {
    echo "<option selected value=\"$row[0]\">$row[1]</option>\n";
    $found="1";
    $graphcomment=urlencode($row[1]);
   }
   else {
    echo "<option value=\"$row[0]\">$row[1]</option>\n";
    
  }
}
if (empty($found)) {
    $int_id=$firstval;
}
     

echo "</select><BR><form action=\"index.php\" method=\"post\">Last : <select name=\"daysview\" onChange=\"this.form.submit()\">";
$choosedays = array (
	'1' => '24 hours',
        '2' => '48 hours',
	'7' => '1 week',
	'14' => '2 weeks',
	'21' => '3 weeks',
	'28' => '4 weeks',
        '35' => '5 weeks',
	'42' => '6 weeks'
	);
if (empty ($daysview)) {
	$daysview='1';
	}
	
while (list ($days,$daysindicator) = each($choosedays)) {
  if ($days==$daysview) {
	echo "<option selected value=\"$days\">$daysindicator</option>\n";
        }
  else {
	echo "<option value=\"$days\">$daysindicator</option>\n";
	}
}
echo "</select><BR><BR>";
$today = getdate();	
$hour = $today['hours'];	
$minutes = $today['minutes'];	
$seconds = $today['seconds'];
    
$stopday=  mktime (date ("H"), date ("i"), date ("s"), date("m"), date ("d") , date("Y"));
	 
$startday  = mktime (date ("H"), date ("i"), date ("s"), date("m"), date ("d") - $daysview, date("Y"));
$stopday =date ("Y-m-d H:i:s", $stopday);
$startday =date ("Y-m-d H:i:s", $startday);
print ("current date and time is $stopday <BR><BR>");
$stopday=urlencode ($stopday);
$startday=urlencode ($startday);
print ("<img src=graph.php?database=worldweather&table=$int_id&col=temp&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=press&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=humid&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=speed&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysviewt>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=dir&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=visib&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=chill&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=height1&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=height2&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=height3&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=phenom1&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=phenom2&start$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
print ("<img src=graph.php?database=worldweather&table=$int_id&col=dew&start=$startday&stop=$stopday&comment=$graphcomment&days=$daysview>\n");
?>
</center>
</body>
Return current item: Worldweather