Mysqli更新查询不起作用,没有错误

时间:2017-02-06 16:15:56

标签: php mysql database mysqli

这是我正在研究的一个学校项目,我现在已经调试了6个小时并且有点沮丧。

我有一个页面,它在HTML输入标记中显示表格数据,同时,我点击更新链接时对其进行了更新查询。但到目前为止它还没有发挥作用。

<?php
    include_once 'admindbconnect.php';

    if (isset($_GET['delete'])) {
        $query = mysqli_query($dbcon, "DELETE FROM userstable WHERE userID=".$_GET['delete']);
        header("Location: $_SERVER[PHP_SELF]");
    }

    if(isset($_POST['edit'])) {
        $query = $dbcon->query("UPDATE userstable SET username='".$_POST['viewUsername']."', userPassword='".$_POST['viewPassword']."', userEmail='".$_POST['viewEmail']."' WHERE id=".$_GET['edit']);
        mysqli_query($dbcon, $query);
        header("Location: admin.php");
    }

?>

<!DOCTYPE html>
<html>
<head>
    <title>YOU ADMIN NOW BRAH</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<center>
    <div class="fullContainer">
        <div class="header">
            <h1>DYLAN'S CONFIDENTIAL USER DATA BRAH</h1>
        </div>
        <div class="subtext">
            <h4>BE VERY SCARED BECAUSE U IN DEEP WATERS NOW BRAH</h4>
        </div>
        <br>
        <div class="adminHeader">
            <h1>DIS BE LIKE ALL DA USER DATA BRAH</h1>
            <h4><span class="blacky">BRAH DONT WORRY YOU CAN ADD DATA </span><span class="here"><a href="adminAdd.php">HERE</a></span></h4>
        </div>
        <br>
        <br>
        <div class="form">
            <table width="50%" align="center">
                <th>ID</th>
                <th>Username</th>
                <th>Password</th>
                <th>Email</th>
                <th colspan="2">Operations</th>

                <?php
                    $query = $dbcon->query("SELECT * FROM userstable");
                    while ($row=mysqli_fetch_assoc($query)) {
                ?>
                        <form action="" method="GET">
                        <tr>
                            <td>
                                <input name="viewID" value="<?php echo $row['userID']?>">
                            </td>
                            <td>
                                <input name="viewUsername" value="<?php echo $row['username']?>">
                            </td>
                            <td>
                                <input name="viewPassword" value="<?php echo $row['userPassword']?>">
                            </td>
                            <td>
                                <input name="viewEmail" value="<?php echo $row['userEmail']?>">
                            </td>
                            <td>
                                <span class="blacky"><a href="?edit=<?php echo $row['userID'];?>" onclick="return confirm('Are you sure you want to edit?');"> Update</a>
                                </span>
                            </td>
                            <td>
                                <span class="Delete"> <a href="?delete=<?php echo $row['userID'];?>" onclick="return confirm('Are you sure you want to delete?');"> Delete</a>
                                </span>
                            </td>

                <?php
                    }
                ?>
        </form>
        </div>
    </div>
</center>
</body>
</html>

编辑:有人标记这是重复的&#34;如何在不同环境中获取mysqli错误?&#34;但这不是我的问题,我的问题是它为什么不更新。

0 个答案:

没有答案