Jump to content

Update multiple records from one submit


andygt

Recommended Posts

Hi,

I have a table that displays a list of records. Each row represents an individual record in the database.

The end user will have the ability to check a series of boxes for any of the records and then submit the data back to the database. This will then update all the records.

My problem lies in creating a multidimensional array for the form. Right now if I print out the POSTed array I see

[code]
Array
(
    [recid] => Array
        (
            [0] => 5137
            [1] => 4623
            [2] => 6694
            [3] => 6505
            [4] => 6364
            [5] => 2677
        )

    [WebKickoffCheck] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 1
        )
    [Submit] => Submit
)[/code]

How can I get this to be a multidimensional array so that I can use a foreach to then loop through each table row and post the data back to the database? Right now I have several different arrays that I would much rather loop through once than write separate loops for.

The form is below

[code]<table>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="Overview">
$countRows = 0;
foreach ($projectList as $value) {
echo "<tr> \n
<td>";
echo '<input name="recid['.$countRows.']" type="hidden" value="'.$value[10].'" />';
?>
<input <?php if (!(strcmp($value[3],1))) {echo "checked=\"checked\"";} ?> name='WebKickoffCheck[<?php echo $countRows; ?>]' type='checkbox' value='1' >

...rest of fields
</td>
</tr>
</form>
</table>[/code]

Many thanks in advance for any help

Andy
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.