Note that there are some explanatory texts on larger screens.

plurals
  1. POI cannot update multiple columns, only one will update
    primarykey
    data
    text
    <p>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!</p> <p>Here is the working code for the table:</p> <pre><code>&lt;table width="100%" border="0" cellspacing="1" cellpadding="0"&gt; &lt;tr&gt; &lt;td&gt;&lt;form name="frmactive" method="GET" action="assigncases1.php"&gt; &lt;table width="100%" border="0" cellpadding="3" cellspacing="1"&gt; &lt;tr&gt; &lt;select name="assigned_to"&gt; &lt;option value=""&gt;&lt;/option&gt; &lt;option value="Kristin Dodd"&gt; Kristin Dodd &lt;/option&gt; &lt;option value="Matt Ursetto"&gt; Matt Ursetto &lt;/option&gt; &lt;option value="Derek Bird"&gt; Derek Bird &lt;/option&gt; &lt;option value="John Castle"&gt; John Castle &lt;/option&gt; &lt;option value="Martin Delgado"&gt; Martin Delgado &lt;/option&gt; &lt;/select&gt; &lt;br&gt; &lt;input type='submit' value = 'Assign'&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td colspan="4" align="center"&gt;&lt;strong&gt;Update multiple rows in mysql with checkbox&lt;br&gt; &lt;/strong&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td align="center" bgcolor="#FFFFFF"&gt;&lt;/td&gt; &lt;td align="left"&gt;&lt;strong&gt;Name&lt;/strong&gt;&lt;/td&gt; &lt;td align="left"&gt;&lt;strong&gt;SSO&lt;/strong&gt;&lt;/td&gt; &lt;td align="left"&gt;&lt;strong&gt;case_status&lt;/strong&gt;&lt;/td&gt; &lt;td align="left"&gt;&lt;strong&gt;Assigned To:&lt;/strong&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php $result=mysql_query($sql); $count=mysql_num_rows($result); while($rows=mysql_fetch_array($result)){ ?&gt; &lt;tr&gt; &lt;td align="center"&gt;&lt;input name="checkbox" type="checkbox" id="checkbox[]" value="&lt;? echo $rows['id']; ?&gt;"&gt;&lt;/td&gt; &lt;td&gt;&lt;? echo $rows['full_name']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;? echo $rows['sso']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;? echo $rows['case_status']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;? echo $rows['assigned_to']; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;tr&gt; &lt;td colspan="5" align="center"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>And this is what I have for the php page that take the info. </p> <pre><code>// 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 "&lt;h3&gt;You forgot to enter a required field. Please try again.&lt;/h3&gt;&lt;br&gt;"; } // if successfully updated. else if($assigned_to !== "") { echo "&lt;b&gt;Update Successful&lt;/b&gt;&lt;br&gt;"; echo "&lt;br&gt;This case was assigned to:&lt;b&gt; $assigned_to&lt;/b&gt;&lt;br&gt;"; echo "&lt;br&gt;To see the change go back and click on &lt;b&gt;Refresh Page&lt;/b&gt; 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"; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload