Location: PHPKode > scripts > Cities of the world > cities-of-the-world/test.php
<?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 */
require("class_cities.inc");

/* 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">
<html>
<head>
<title>Your Page Title</title>

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

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

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