开发者

PHP/Html form with mysql database information

开发者 https://www.devze.com 2023-03-05 15:18 出处:网络
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 e

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消