Updating Multiple Records Based on A checkbox in a Repeated

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
amdorsey
Forum Newbie
Posts: 19
Joined: Mon Dec 06, 2004 2:46 pm

Updating Multiple Records Based on A checkbox in a Repeated

Post 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.
User avatar
xisle
Forum Contributor
Posts: 249
Joined: Wed Jun 25, 2003 1:53 pm

Post 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']."">
amdorsey
Forum Newbie
Posts: 19
Joined: Mon Dec 06, 2004 2:46 pm

Post by amdorsey »

How would you loop through the array when updating?
valen53
Forum Contributor
Posts: 137
Joined: Tue Aug 27, 2002 9:29 am

Post by valen53 »

if (isset($_POST['checkbox'])) {
foreach ($_POST['checkbox'] as $value) {
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

take a look at THIS thread

or THIS Looks rather the same.. didnt study it.. so could be wrong
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

This thread continues here. Please don't cross post, read the forum's guidelines.

-- Scorphus
Post Reply