Viewing file: 19.php (2.58 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
// Include the PEAR::SOAP client class
require_once('SOAP/Client.php');
// Include the Session class
require_once('Session/Session.php');
// Instantiate the Session class
$session=new Session();
// Instantiate the SOAP_WSDL class using the online document
$wsdl=new SOAP_WSDL('http://live.capescience.com/wsdl/GlobalWeather.wsdl');
// Get the proxy class for the service
$stationInfo = $wsdl->getProxy();
// If the Countries session variable exists, use it
if ( $session->get('Countries') ) {
// Get the data from the local session variable
$countries = $session->get('Countries');
} else {
// Otherwise get a list of countries from the service
$countries = $stationInfo->listCountries();
$session->set('Countries',$countries);
}
// A select box to choose a country
$select = "<select name=\"country\">\n";
foreach ( $countries as $country ) {
if ( $country == 'switzerland' ) {
$select .= "<option selected>".$country."</option>\n";
} else {
$select .= "<option>".$country."</option>\n";
}
}
$select .= "</select>";
// Initialize a variable to store a table
$table='';
// If a country search has been performed...
if ( isset ( $_GET['country'] ) && in_array($_GET['country'],$countries) ) {
// Start building the table
$table = "<table>\n";
$table.= "<tr>\n<th>Airports in ".$_GET['country']."</th>\n</tr>\n";
// Use the services searchByCountry() method
$country = $stationInfo->searchByCountry($_GET['country']);
// Display the airports in the country as table rows
foreach ( $country as $airport ) {
$table.="<tr>\n<td>".$airport->string."</td>\n</tr>\n";
}
$table .= "</table>";
}
?>
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Global Weather Service </title>
<meta http-equiv="Content-type" content="text/html"
charset="iso-8859-1" />
<style type="text/css">
body, td {
font-size: 13px;
font-family: verdana;
color: navy
}
b {
font-weight: bold;
}
form {
margin: 0px;
}
input, select {
font-size: 12px;
font-family: verdana;
background-color: silver;
color: black;
}
</style>
</head>
<body>
<form method="GET" action="<?php echo ( $_SERVER['PHP_SELF'] ); ?>">
<table>
<tr>
<td><b>Pick a Country:</b></td>
<td><?php echo ( $select ); ?></td>
<td><input type="submit" value=" Search "></td>
</tr>
</table>
</form>
<?php echo ( $table );?>
</body>
</html>
|