无法编辑第二个用户

时间:2019-06-12 07:58:46

标签: php jquery html

我有一个页面,您可以在其中编辑用户。如果单击“编辑”按钮,则会重定向到可以编辑该用户的页面。它非常适合第一人称,但是当我单击第二个用户的编辑按钮时,它什么也没做。没有错误就没有。您不会重定向到页面。

我的PHP

function getUsers($orgID, $type)
{
    require 'functions/conn.php';
    $sql = "SELECT users.*, parts.*, keuze.* FROM ((users INNER JOIN parts ON users.part_id = parts.part_id) INNER JOIN keuze ON users.keuze_ID = keuze.ID) WHERE users.org_id = '" . $orgID . "' AND users.active = '" . $type . "';";
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            echo '<tr id="' . $row['user_id'] . '" class="changeUser">';

            echo '  <td>' . $row['fnln'] . '</td>';
            echo '  <td>' . $row['username'] . '</td>';
            echo '  <td>' . $row['name'] . '</td>';
            echo '  <td>' . $row['keuze'] . '</td>';
            echo '  <td>';
                echo '      <button class="button button-orange" id="btnChangeUser">Eind tijd</button>';

            if ($row['active'] == 0 || $row['active'] == 2) {
                echo '      <button class="button button-green" onclick="approveOne('.$row['user_id'].', '.$_SESSION['org_id'].')">Approve</button>';
            }
            echo '      <button class="button button-red" onclick="deleteFromRelation(' . $row['user_id'] . ');">Delete</button><br/>';
            echo '  </td>';
            echo '</tr>';
        }
    }
}

我的Jquery

<script>

$("#btnChangeUser").click(function () {
    var userID = $(".changeUser").attr('id');
    window.location.href = "changeuser?user=" + userID + "";
});

function changeItem(userID) {
    window.location.href = "changeuser?user=" + userID + "";
}

</script>

我期望的是,如果我单击第二个用户的编辑按钮,它将重定向我。

修改

第二行是我无法编辑的行。  enter image description here

2 个答案:

答案 0 :(得分:2)

您分配了相同的ID。这是违反规则的行为。代替if numberOfDevicesAlreadyInTheDB < 3 { let newDevice = String("Device\(numberOfDevicesAlreadyInTheDB+1)") let userDeviceRef = self.ref.child("Devices").child(FIRAuth.auth()!.currentUser!.uid) userDeviceRef.updateChildValues([newDevice: DeviceInfo]) // Also you need to log your second/third device entry here self.ref.child("UserDevices").childByAutoId().setValue([ "ImageUrl":profileImageUrl!, "DeviceName":self.DeviceName.text!, "Description":self.Description.text!, "Category":self.itemSelected, "name": self.globalUserName, "email":self.globalEmail , "city": self.globalCity, "phone": self.globalPhone ] as [String : Any]) } 使用idclass

data-id

要捕获数据ID,请使用带有<button class="button button-orange" data-id="' . $row['user_id'] . '">Eind tijd</button>'; 的按钮类:

this

答案 1 :(得分:1)

相关问题