如何從選擇選項更新數據庫。從鏈接中選擇選項更新數據庫
如果選擇了測試,則從db行更新用戶標識。
<form action="action.php?id=<?php echo $dnn['id'] ?>" method="post">
<select name="op">
<option value="test">test</option>
<option value="test2">test2</option>
</select>
<input name="submit" type="submit" value="submit" />
</form>
<?php
if (isset($_POST['submit']))
{
if ($_POST['op'] == "test")
{
$sql = "UPDATE * from users SET increment = increment + 1 WHERE id = '".$id."'";
mysql_query($sql);
}
else
{
echo "test2 is selected can't update the db";
}
}
?>
什麼似乎是問題? – samayo
'UPDATE users'而不是'UPDATE * from'' –
不更新db行 –