我正在尝试更新表上的数据无法更新,但是可以将数据发送到SQL命令更新之前的最后一节。
这是我在第一页上的按钮
<a href="Edit.php?Edit=<?php echo $UID; ?>" onclick="document.getElementById('bgmodal');"><i class="fa fa-edit" style="font-size:20px;color:Green;"></i></a>
这是我的更新页面
บันทึก的意思是“保存”
แก้ไขข้อมูล的意思是“数据编辑”
โปรดตรวจสอบข้อมูลก่อนอนบันทึก的意思是“保存前请检查”
ต้องการบันทึกข้อมูลนี้หรือไม่?表示“您要保存吗?”
<?php
include('connect.php');
if (isset($_GET['Edit'])) {
$editid = $_GET['Edit'];
$rez = $mysqli->query("SELECT * FROM user_tbl WHERE User_ID ='$editid'");
$resut = mysqli_fetch_array($rez,MYSQLI_ASSOC);
$UsID = $resut['User_ID'];
$UsName = $resut['User_Name'];
$Dpt = $resut['Dept_ID'];
}
?>
<div id="bgmodal" class="bg-modal">
<div id="modalcont" class="bg-content">
<a href="User.php" class="close" >+</a>
<form method="GET" action="Edit.php" >
<H1 style="font-family: sans-serif; text-decoration: underline;" >แก้ไขข้อมูล</H1>
<h2 style="font-family: sans-serif; color: red; font-size: 20px" >**โปรดตรวจสอบข้อมูลก่อนบันทึก**</h2>
<input class="IP1" type="text" name="Users_text" value="<?php echo $UsID ?>">
<input class="IP1" type="text" name="Uname_text" value="<?php echo $UsName ?>">
<input class="IP1" type="text" name="Dpart_text" value="<?php echo $Dpt ?>">
<input class="btn" type="submit" name="Edited" value="บันทึก" onclick="return confirm('ต้องการบันทึกข้อมูลนี้หรือไม่?');">
</form>
</div>
</div>
<?php
if (isset($_GET['Edited'])){
$IDu = $_GET['Users_text'];
$NUs = $_GET['Uname_text'];
$Dpu = $_GET['Dpart_text'];
echo "<script> alert('".$NUs."') </script>"; #I'm test for check the data is come to this section
$mysqli->query("UPDATE user_tbl SET User_ID = '$IDu' , User_Name = '$NUs' , Dept_ID = '$Dpu' WHERE User_ID = 'IDu' ") or die (mysqli_error());
}
?>
答案 0 :(得分:0)
因为表单发送到edit.php,所以您应该将此代码带到那里
<?php
if (isset($_GET['Edited'])){
$IDu = $_GET['Users_text'];
$NUs = $_GET['Uname_text'];
$Dpu = $_GET['Dpart_text'];
echo "<script> alert('".$NUs."') </script>";
#I'm test for check the data is come to this section
$mysqli->query("UPDATE user_tbl SET User_ID = '$IDu' , User_Name = '$NUs' , Dept_ID = '$Dpu' WHERE User_ID = 'IDu' ") or die (mysqli_error());
}
?>