You are here: Re: Forms and PHP « PHP Programming Language « IT news, forums, messages
Re: Forms and PHP

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация