Currently I am working on an admin module portion of my site to allow users that are level > 1
to change other users levels on the fly with a simple click of a button. In my code I am echoing all users that are level <1
in a table where a user with the level
of 2
will be able to change the other user(s) levels…
This is what my module looks like as of right now. and this is what my code currently looks like for this particular module.
Here is an image to clerify a bit more: If I hit the button highlighted in yellow it should change the level of the user highlighted in yellow; same goes for the one highlighted in purple.
What I am asking / confused about is how I can tie each button (Change to level 1
& Change to level 2
) to the username in that row. When I tried doing this myself, I tried to use the query:
// Assigned to level 1 button
if (isset($_POST['changeLevel_1'])) {
$query = dbConnect()->prepare("UPDATE users SET level = '1' WHERE username = $row['username']");
$query->execute();
}
… but unfortunately all that did was update the last user in the database instead of the user in the same row as the button I clicked (if that makes sense).
Any and all help is greatly appreciated,
Codi B-Smith