|
Posted by Chenky on 10/09/06 07:40
I haven't used AJAX (or heard of it) so Colin's probably more
knowledgeable at that one.
Assuming you're using MySQL, a simple way to achieve what you need is
something like this...
<select name="selectedcity">
<?
// Next line is name of database
$db = "mydatabase";
// In next line replace localhost with IP address of database server,
but alot of them are just localhost, and replace username and password
with the obvious
$link = @mysql_connect("localhost", "username", "password");
if (! $link) {
die("Error: Couldn't connect to MySQL Database");
}
mysql_select_db($db) or die("Error: Couldn't open MySQL Database");
// Replace name with the column heading containing the city name
$query = mysql_query("SELECT * FROM cities where name!="");
while ($city = mysql_fetch_array($query)) {
echo "<option value=" . $city['name'] . ">" . $city['name'];
}
?>
</select>
This will print a new...row or thing lol in the drop down list for
every city listed in the database. Any other help just ask ;)
Josh
Navigation:
[Reply to this message]
|