Home › Forums › Back End › Help me echo an individual $row? › Reply To: Help me echo an individual $row?
Assuming you are flagging multiple users for an admin_level
change via something like a checkbox, you would have something like this:
<input type="checkbox" name="change_id[]" value="<?php echo $row['id']; ?>">
The brackets after change_id
indicate that this is an array, so now you have an array of user IDs that are subject to the change, under $_POST['change_id']
From there you can use IN()
to modify your ‘results’ query along the lines of:
$sth2 = $conn->prepare("SELECT id, username, email, admin_level FROM users WHERE id IN(' . implode(",", $_POST['change_id']) .'");
Note: For the purposes of sanitization you would likely first want to make sure that $_POST['change_id']
exists and is an array, as implode()
will return an error otherwise.
Resources: