Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
amdorsey
Forum Newbie
Posts: 19 Joined: Mon Dec 06, 2004 2:46 pm
Post
by amdorsey » Thu Dec 09, 2004 11:17 am
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 { ?>
<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ї'date_created']; ?></td>
<td class="style16"><?php echo $row_Log_Displayї'event']; ?></td>
<td class="style16"><?php echo $row_Log_Displayї'region']; ?></td>
<td class="style16"><?php echo $row_Log_Displayї'quanity_sets']; ?> Sets of <?php echo $row_Log_Displayї'quanity_each']; ?> Each </td>
<td><span class="style16"><?php echo $row_Log_Displayї'size']; ?> <?php echo $row_Log_Displayї'sort']; ?></span></td>
<td><span class="style16"><?php echo $row_Log_Displayї'description']; ?></span></td>
<td class="style16"><span class="style16 style19"><span class="style21"><?php echo $row_Log_Displayї'status']; ?></span></span></td>
</tr>
<?php } while ($row_Log_Display = mysql_fetch_assoc($Log_Display)); ?>
I just need the code for updating based on the checkboxes.
xisle
Forum Contributor
Posts: 249 Joined: Wed Jun 25, 2003 1:53 pm
Post
by xisle » Thu Dec 09, 2004 1:18 pm
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ї]" value="".$row_Log_Displayї'id']."">
amdorsey
Forum Newbie
Posts: 19 Joined: Mon Dec 06, 2004 2:46 pm
Post
by amdorsey » Thu Dec 09, 2004 2:51 pm
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 » Fri Dec 10, 2004 12:42 am
if (isset($_POST['checkbox'])) {
foreach ($_POST['checkbox'] as $value) {
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Fri Dec 10, 2004 1:06 am
take a look at
THIS thread
or
THIS Looks rather the same.. didnt study it.. so could be wrong
scorphus
Forum Regular
Posts: 589 Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:
Post
by scorphus » Fri Dec 10, 2004 12:49 pm
This thread continues
here . Please don't cross post, read the forum's
guidelines .
-- Scorphus