Location: PHPKode > scripts > Cities of the world > cities-of-the-world/test.php
Author:  Ahmet M. Okar (hide@address.com)
Package: Cities_of_the_World
File:    test.php
Desc:    PHP script to demonstrate the usage of the class.

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA.

// Change these variables to whatever you have used in 'cities_sql.php' file.
$db_host = "localhost";
$db_user = "";
$db_pass = "";
$db_name = "countries_cities";
$db_table = "cities";
$country = ""; // two letter country_code of the country for which the cities will be shown.

/* require(), instead of include() to abort execution if the class is not found */

/* create a new instance of the class */
$cities = new cities($db_host, $db_user, $db_pass, $db_name);

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>Your Page Title</title>

<!-- embed JavaScript to control whether the second dropdown list will be enabled/disabled -->
<? echo $cities->java_script($country) ?> 

<form action="<? echo $_SERVER['PHP_SELF'] ?>" method="post">
    <!-- create countries' dropdown list -->
	<td><? echo $cities->country_list($db_table) ?></td>

    <!-- determine the field caption -->
	<td><? echo $cities->caption($country) ?></td>
    <!-- create cities' dropdown list -->
	<td><? echo $cities->city_list($db_table, $country) ?></td>
	<td colspan="2" align="center"><input type="submit" value=" SUBMIT "></td>
Return current item: Cities of the world