簡體   English   中英

我無法使用php更新數據庫

[英]I can't update my database with php

我嘗試更新表上的數據無法更新,但是可以將數據發送到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());

    }
?>

因為表格發送到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());
}
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM