From: "andy amol" <[EMAIL PROTECTED]> > 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.
You still have to check. Just because you provide a discreet number of options in a <select> box doesn't mean that's really all the user can choose from. There are many ways to manipulate the data. That being said, just create a loop as you draw items from your database. <?php echo '<select name="something" size="1">'; $sql = "SELECT name FROM products WHERE ..."; $result = query($sql); while($row = fetch_assoc($result)) { echo "<option value=\"{$row['name']}\">{$row['name']}</option>\n"; } echo "</select>"; I don't know what database you're using, so query() and fetch_assoc() are generic. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php