If it is a MySWL database, the following code works great
<?
$sql = "select choice, description from views";
$result = mysql_query($sql) or die(mysql_error());
$viewing = "";
$viewing .= "<select name=\"view_code\">\n";
while ($view_list = mysql_fetch_array($result))
{
$view_code = $view_list[choice];
$view_desc = stripslashes($view_list[description]);
$viewing .= "<option value=\"$view_code\">$view_desc</option>\n";
}
$viewing .= "</select>";
?>
Of course you'll have to change it to fit your needs, but I just have a
while loop that gets the information and then dumps each line it gets
out to a temp variable. On the pages that include this one is where the
displaying comes out.
HTH,
Robert
-----Original Message-----
From: andy amol [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 20, 2004 11:53 AM
To: David Robley; [EMAIL PROTECTED]
Subject: [PHP-DB] Drop-down box in php
hi,
I would like to know how to create and populate drop down boxes in
php. I want the value to be populated from database. What I am try to do
is to provide the forign key value as combo box option, so that I do not
have to check for referential integrity.
Also if you can help me with a date validation program I will be
grateful.
Thanks in advance.
---------------------------------
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25�
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php