theaussie
asked on
Populating a dropdown box with data from a MySQL table.
I am attempting to populate a dropdown menu with data from a table.
The tableX consists of 5 fields.
id
field1
field2
field3
field4
I need the information if database.field3 to popualte the dropdown box, and am using the following script:
<?
$connection = mysql_connect("localhost", "user","pa sswordr");
$fields = mysql_list_fields("databas e", "tableX", $connection);
$columns = mysql_num_fields($fields);
echo "<form action=page_to_post_to.php method=POST><select name=Field>";
for ($i = 0; $i < $columns; $i++) {
echo "<option value=$i>";
echo mysql_field_name($fields, $i);
}
echo "</select></form>";
?>
This though populates the dropdown with the field names:
id
field1
field2
field3
field4
and not the specific data in field 3.
What am I missing here.?
The tableX consists of 5 fields.
id
field1
field2
field3
field4
I need the information if database.field3 to popualte the dropdown box, and am using the following script:
<?
$connection = mysql_connect("localhost",
$fields = mysql_list_fields("databas
$columns = mysql_num_fields($fields);
echo "<form action=page_to_post_to.php
for ($i = 0; $i < $columns; $i++) {
echo "<option value=$i>";
echo mysql_field_name($fields, $i);
}
echo "</select></form>";
?>
This though populates the dropdown with the field names:
id
field1
field2
field3
field4
and not the specific data in field 3.
What am I missing here.?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW, why B !?