Dec 4, 2001 #1 eter4 MIS Mar 13, 2001 30 CA how can I display the contents of a MySQL table in a dropdown box. I only need to return 1 column of data. Ex if I have all the states in a table.... I want to have the states appear in a dropdown list. Thanks
how can I display the contents of a MySQL table in a dropdown box. I only need to return 1 column of data. Ex if I have all the states in a table.... I want to have the states appear in a dropdown list. Thanks
Dec 5, 2001 #2 piti Technical User Apr 12, 2001 627 SK assuming you want the drop down box on a web page and using php, then 1. run your select query $result = mysql_query("select state_id, state_name from table", $dbconnection); 2.populate your combo $html_output = '<select name="states">'; while($state = mysql_fetch_array($result)) { $html_output .= '<option value="'.$state["state_id"].'">'.$state["state_name"].'</option>'; } $html_output .= '</select>'; echo $html_output; hope this helps Upvote 0 Downvote
assuming you want the drop down box on a web page and using php, then 1. run your select query $result = mysql_query("select state_id, state_name from table", $dbconnection); 2.populate your combo $html_output = '<select name="states">'; while($state = mysql_fetch_array($result)) { $html_output .= '<option value="'.$state["state_id"].'">'.$state["state_name"].'</option>'; } $html_output .= '</select>'; echo $html_output; hope this helps