You mean <select></select> html dropdown-s?

print '<select name="sg">';
$r = mysql_query("SELECT id, field1, fieldn FROM table WHERE fieldn = 'sg'");
while($RESULT = mysql_fetch_array($)) {
        print '<option value="'.$RESULT['id'].'">'.$RESULT['fieldn']'.</option>';
print '</select>';

Validating: just check the $_POST['sg'] value, against is_numeric(), then you can do a SELECT, to check whether the id exists.

You can find some more examples, on php net manual pages


andy amol wrote:

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 ( To unsubscribe, visit:

Reply via email to