Submit updates to a mysql table through checkboxes

I am having a little trouble. what i am trying to do is retrieve a list of unauthorized users, and list them (no problem, got that part taken care of).

Where i am running into trouble is after listing the unauthorized users in a table, i want the admin to be able to click a checkbox next to each of the user he wants to authorize and then update the users authorization status.

How would i go about implementing this?
	  if($_SESSION['permissions'] == "2")
$con = mysql_connect($databse, $user, $dbpass);
if (!$con)
  die('Could not connect: ' . mysql_error());
mysql_select_db($table, $con);
$result = mysql_query("SELECT * FROM Users WHERE authorized = '0'");
echo "<table width='200' bgcolor='000000' border='1'>
<th width='25%'>Username</th>
<th width='7%'>Authorize</th>
while($row = mysql_fetch_array($result))
  echo "<tr>";
  echo "<td>" . $row['username'] . "</td>";
  echo "<td>" 
  <form name="authorize" action="authorize.php" method="post">
  <input type="radio" name="authorize" />
  echo "</tr>";
echo "</table>";
	<input type="submit" name="Submit" value="Authorize" />

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The idea is like putting a checkbox (all with the same name) next to each username

 <input type="checkbox" name="userlist[]" value="$userid"> , where $userid is the user of each username.

After submit the form , you can get the selected list by

foreach($_POST['userlist'] as &$value) {
    echo $value;

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
Radio buttons are mutually exclusive - even if you have 5 of them, you get no more than one in the $_POST input.  You can get zero, if the client selected nothing.

Checkboxes are not mutually exclusive - You can get zero or more (up to the total number of checkboxes) depending on what the client selected.  A checkbox that is not checked does NOT come through in the $_POST input.  Why is this important?  

If you put up a form with a checkbox that is checked (ie: a member in good standing) and the client un-checks it, the checkbox will be absent in $_POST - you can't check for a value of "off" or something helpful like that.  Instead you have to know that the checkbox exists and know that its absence in $_POST means a change of state.  A nuisance, but forewarned is forearmed!

I think when you are testing with these things it is helpful to put this into the script: var_dump($_POST);

best of luck with your project, ~Ray
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.