hi, I am using the following code, but it is not populating my script. If you can help I would be grateful. I am using mysql as database. <? $sql = "SELECT course_id FROM course"; $sql_result = mysql_query($sql) or die("Couldn't execute query."); while ($row = mysql_fetch_array($sql_result)) { $type = $row["course_id"]; $typedesc =$row["dept_id"]; $option_block .= "<OPTION value=\"$type\">$typedesc</OPTION>"; } ?> <SELECT name="selecttype" id="selecttype"> <? echo "$option_block"; ?> </SELECT> thanks. "John W. Holmes" <holmes072000@xxxxxxxxxxx> wrote: From: "andy amol" > 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 box doesn't mean that's really all the user can choosefrom. There are many ways to manipulate the data.That being said, just create a loop as you draw items from your database.echo ''; $sql = "SELECT name FROM products WHERE ..."; $result = query($sql); while($row = fetch_assoc($result)) { echo "{$row['name']}\n"; } echo ""; 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 --------------------------------- Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25¢