Page 1 of 1

Updating Multiple Records Based on A checkbox in a Repeated

Posted: Thu Dec 09, 2004 11:17 am
by amdorsey
Question for the Pros:

I want to display records in a database. A single Row will be made a repeat region to display all the records. Simple. In that row I also want a checkbox, next to each record. Based on the checkboxes checked, I want to UPDATE those records in the database. Here is the code to display my table.

Code: Select all

<?php do &#123; ?>
    <tr align="left" valign="middle" bgcolor="#FFFFFF">
      <td align="center" valign="middle" class="style16"><input name="checkbox" type="checkbox" value="checkbox"></td>
      <td class="style16"><?php echo $row_Log_Display&#1111;'date_created']; ?></td>
      <td class="style16"><?php echo $row_Log_Display&#1111;'event']; ?></td>
      <td class="style16"><?php echo $row_Log_Display&#1111;'region']; ?></td>
      <td class="style16"><?php echo $row_Log_Display&#1111;'quanity_sets']; ?> Sets of <?php echo $row_Log_Display&#1111;'quanity_each']; ?> Each </td>
      <td><span class="style16"><?php echo $row_Log_Display&#1111;'size']; ?> <?php echo $row_Log_Display&#1111;'sort']; ?></span></td>
      <td><span class="style16"><?php echo $row_Log_Display&#1111;'description']; ?></span></td>
      <td class="style16"><span class="style16 style19"><span class="style21"><?php echo $row_Log_Display&#1111;'status']; ?></span></span></td>
    </tr>
    <?php &#125; while ($row_Log_Display = mysql_fetch_assoc($Log_Display)); ?>
I just need the code for updating based on the checkboxes.

Posted: Thu Dec 09, 2004 1:18 pm
by xisle
start with posting the id#s in an array, then loop through the array and update each row

Code: Select all

<input type="checkbox" name="row_ids_to_update&#1111;]" value="".$row_Log_Display&#1111;'id']."">

Posted: Thu Dec 09, 2004 2:51 pm
by amdorsey
How would you loop through the array when updating?

Posted: Fri Dec 10, 2004 12:42 am
by valen53
if (isset($_POST['checkbox'])) {
foreach ($_POST['checkbox'] as $value) {

Posted: Fri Dec 10, 2004 1:06 am
by ol4pr0
take a look at THIS thread

or THIS Looks rather the same.. didnt study it.. so could be wrong

Posted: Fri Dec 10, 2004 12:49 pm
by scorphus
This thread continues here. Please don't cross post, read the forum's guidelines.

-- Scorphus