Setting initial option value of dropdown box
Posted: Tue Feb 15, 2011 5:08 pm
Hi everyone.
I have a dropdown box retrieving information from a column in a table. I wish the initial value to be <select from list>. Can anyone suggest a way to do that? thx.
<?php
$query="select CategoryName from categorytypes";
$result = mysql_query($query) or die(mysql_error());
$dropdown = "<select name='CategoryTypes'>";
while($row = mysql_fetch_assoc($result)) {
$dropdown .= "\r\n<option value='{$row['CategoryName']}'>{$row['CategoryName']}</option>";
}
$dropdown .= "\r\n</select>";
echo $dropdown;
?>
I have a dropdown box retrieving information from a column in a table. I wish the initial value to be <select from list>. Can anyone suggest a way to do that? thx.
<?php
$query="select CategoryName from categorytypes";
$result = mysql_query($query) or die(mysql_error());
$dropdown = "<select name='CategoryTypes'>";
while($row = mysql_fetch_assoc($result)) {
$dropdown .= "\r\n<option value='{$row['CategoryName']}'>{$row['CategoryName']}</option>";
}
$dropdown .= "\r\n</select>";
echo $dropdown;
?>