Login   Register  
PHP Classes

File: testdist.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Thomas Jakober  >  distance class  >  testdist.php  >  Download  
File: testdist.php
Role: Example script
Content type: text/plain
Description: Example file
Class: distance class
Calculate the air distance between two cities
Author: By
Last change:
Date: 5 years ago
Size: 2,198 bytes


Class file image Download

 * testdist.php
 * @version $Id$
 * @copyright 2009

include "distance.class.php";
$d1 '';
$d2 '';
$d3 '';
$di '';

if (isset(
$_POST['center'])) {
$di 'Distance';
$oDist = new distance($_POST['center'], $_POST['unit']);
    if (!empty(
$_POST['c1'])) {
$d1 round($oDist->calcDistance($_POST['c1']), 1) . $_POST['unit'];
    if (!empty(
$_POST['c2'])) {
$d2 round($oDist->calcDistance($_POST['c2']), 1) . $_POST['unit'];
    if (!empty(
$_POST['c3'])) {
$d3 round($oDist->calcDistance($_POST['c3']), 1) . $_POST['unit'];
$ct0 = (isset($_POST['center']) ? $_POST['center'] : '');
$ct1 = (isset($_POST['c1']) ? $_POST['c1'] : '');
$ct2 = (isset($_POST['c2']) ? $_POST['c2'] : '');
$ct3 = (isset($_POST['c3']) ? $_POST['c3'] : '');

        <title>Distance Calculator</title>
        <h3>Calculate the Air Distance between Cities</h3>
        <p>Enter cities in the form: 'Z&uuml;rich Switzerland'</p>
        <div id="cdst">
            <form name="dcc" method="post" action="<?=$_SERVER['SCRIPT_NAME']?>">
                <input type="hidden" name="app" value="dic">
                <input type="hidden" name="cmd" value="dst">
                            <select name="unit">
                                <option selected>km</option>
                        <td>Center City</td>
                        <td><input type="text" name="center" value="<?=$ct0?>"></td>
                        <td>City 1</td>
                        <td><input type="text" name="c1" value="<?=$ct1?>"></td>
                        <td class="dist"><?=$d1?></td>
                        <td>City 2</td>
                        <td><input type="text" name="c2" value="<?=$ct2?>"></td>
                        <td class="dist"><?=$d2?></td>
                        <td>City 3</td>
                        <td><input type="text" name="c3" value="<?=$ct3?>"></td>
                        <td class="dist"><?=$d3?></td>
                        <td><button type="submit">Calculate</button></td>