我正在制作一个下拉列表,我希望当用户选择一个值时,保存到数据库。
这是我的代码:
$query = mysql_query("SELECT name FROM store_locator_bundes");
echo '<select name="bundesland-dropdown">';
while ($row = mysql_fetch_array($query)) {
echo '<option value="'.$row['name'].'">'.$row['name'].'</option>';
}
echo '</select>';
条件
if($_POST[$criteria['submit']['name']]) {
// here I am lost, I have to insert the values of the dropdown to store_locator and the field bundes_id
}
谢谢你的帮助;)
答案 0 :(得分:0)
你想要
$_POST['bundesland-dropdown']; // You want the <select> not the <options>'s name
然后插入:
if (isset($_POST['bundesland-dropdown'])){
//mysqli/PDO/whatever database method of insertion you want here
}