PHP/Html form with mysql database information
I want a html with a dropdown menu开发者_如何学Python were it's items are picked up from a mysql database. Then, when I select one of them, I want to be able to use it on a php file. Anybody has an example? Thanks
print '<form method="post" action="submit.php">';
print '<select size="1" name="myselect">';
foreach($dbresults as $r) {
print '<option value="'.$r['field'].'">'.$r['field'].'</option>';
}
print '</select>';
print '<input type="submit" value="Go!" />';
print '</form>';
And on the form's action page:
$chosen_thing = $_POST['myselect'];
You might want to look into how it's done in commonly used CMS applications, e.g. WordPress, Drupal, Joomla, etc.
精彩评论