Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8347735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:27:31+00:00 2026-06-09T07:27:31+00:00

I figured out how to update a table with multiple columns using checkboxes, except

  • 0

I figured out how to update a table with multiple columns using checkboxes, except when more than one checkbox is selected the update will only happen for one of the columns not both. Could someone please help? Thank you!

Here is the working code for the table:

<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="frmactive" method="GET" action="assigncases1.php">
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr>

          <select name="assigned_to">
        <option value=""></option>            
        <option value="Kristin Dodd"> Kristin Dodd </option>
        <option value="Matt Ursetto"> Matt Ursetto </option>
        <option value="Derek Bird"> Derek Bird </option>
        <option value="John Castle"> John Castle </option>
        <option value="Martin Delgado"> Martin Delgado </option>
      </select>
<br>
<input type='submit' value = 'Assign'> 
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="4" align="center"><strong>Update multiple rows in mysql with checkbox<br>
</strong></td>
</tr><tr>
<td align="center" bgcolor="#FFFFFF"></td>
<td align="left"><strong>Name</strong></td>
<td align="left"><strong>SSO</strong></td>
<td align="left"><strong>case_status</strong></td>
<td align="left"><strong>Assigned To:</strong></td>
</tr>
<?php
$result=mysql_query($sql);

$count=mysql_num_rows($result);
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><input name="checkbox" type="checkbox" id="checkbox[]" value="<?        
echo $rows['id']; ?>"></td>
<td><? echo $rows['full_name']; ?></td>
<td><? echo $rows['sso']; ?></td>
<td><? echo $rows['case_status']; ?></td>
<td><? echo $rows['assigned_to']; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5" align="center">&nbsp;</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

And this is what I have for the php page that take the info.

// Retrieve data from database 
$checkbox = $_GET['checkbox'];
$assigned_to = $_GET['assigned_to'];

// update data in mysql database 
$sql="UPDATE rmstable2 SET assigned_to='$assigned_to' WHERE id='$checkbox'";
$result = mysql_query($sql);
$count = mysql_numrows($result);
{
mysql_query("UPDATE `rmstable2` SET `assigned_to` = '$assigned_to'
                         WHERE `id` = '$checkbox'") 
 or die(mysql_error());

}

 //If they did not enter a search term we give them an error 
if ($assigned_to == "")
{ 
echo "<h3>You forgot to enter a required field. Please try again.</h3><br>";  
 } 
// if successfully updated. 
else if($assigned_to !== "")
{
echo "<b>Update Successful</b><br>";
echo "<br>This case was assigned to:<b> $assigned_to</b><br>"; 
echo "<br>To see the change go back and click on <b>Refresh Page</b> if you assigned it
to someone other than you, the case will disappear and show up in their list of      
 assigned cases."; 
}
else {
echo "ERROR";
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:27:32+00:00Added an answer on June 9, 2026 at 7:27 am

    In your HTML, you’re defining your checkboxes with the name checkbox – so only one value will be sent to PHP. To get an array of values, update the checkboxes to be created with name="checkbox[]" and when the form is submitted, you can use the selected values like an array.

    In that case, you’ll be able to loop through each item with:

    $checkbox = $_GET['checkbox'];
    $assigned_to = $_GET['assigned_to'];
    
    foreach ($checkbox as $id) {
        // do a very basic validation to see if the ID is numeric
        if (!is_numeric($id)) continue;
        $sql = 'UPDATE rmstable2 SET assigned_to="' . mysql_real_escape_string($assigned_to) . '" WHERE id=' . (int)$id;
        mysql_query($sql);
    }
    

    Also, as always worth noting, the mysql_* functions are being deprecated and you should consider to start using either mysqli_* or PDO methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update II I Figured this out. When using google maps api, the model must
I am trying to figure out how can I update the petevents table with
UPDATE: OK I figured it out, looks like fread has a filesize limitation, changed
UPDATE OK, I figured it out. I had to call the following for varieties:
I can't figure out the syntax for Mysql update with multiple concatinations. I want
Using a code-first approach I'd like to map a single model to multiple table
I am trying to figure out how I can update my sql query dynamically.
I can't figure out why this simple update command won't work: private void button1_Click(object
I'm trying to figure out how to ask this - so I'll update the
I've been trying to figure out a way to update the interface after each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.