我遇到了将选项值保存到数据库中的问题。一切看起来都很正确,但提交后,数据库中的值不会改变。表单位于检索用户提交的表中,并且consent_id用于更新管理员选项。希望任何人都能发现我错过的内容或应该写的内容。感谢。
这是我的代码:
manageLeave.php
<script type="text/javascript">
$(document).ready(function () {
$("#confirmForm").click(function () {
$("#statusForm").submit();
});
});
</script>
<body>
...
<tr>
<td><?php echo $staffName; ?></td>
<td><?php echo $convertDateFrom; ?></td>
<td><?php echo $convertDateTo; ?></td>
<td><?php echo $reason; ?></td>
<td>
<form method="post" action="doManageLeave.php" id="statusForm" name="statusForm">
<input type="hidden" name="consentId" value="<?php echo $consentId; ?>">
<select name="leaveStatus" data-native-menu="false">
<option value="" disabled selected style="display: none">Please select one...</option>
<option value="1">Approved</option>
<option value="2">Rejected</option>
</select>
</form>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
}
?>
<input type="button" id="confirmForm" value="Submit" />
</body>
doManageLeave.php
$getConsentId = $_POST['consentId'];
$leaveStatus = $_POST['leaveStatus'];
$editQuery = "UPDATE consent SET approval_id = '$leaveStatus' WHERE consent_id = $getConsentId";
$successInsert = mysqli_query($link, $editQuery) or die ("Error Query ". mysqli_error($link));
mysqli_close($link);