[FX.php List] Editing multiple records
Steve Winter
steve at bluecrocodile.co.nz
Wed Aug 9 19:39:48 MDT 2006
Hi Rob,
In a way you've answered the question yourself... a foreach loop...
In the foreach loop that you use yo output the data, instead of outputting
a new form for each item, output a hidden field containing the recID of
the record, plus the other data... appending [] to the end of each name
item (so that it becomes something like <input name="-recid[]"
value="<?php echo $recordID; ?>"> etc... this way you end up with arrays
for each of the records.
I'd also add a final hidden field, that contained the
$returnedData['foundCount'] so that you knew how many records you were
editing...
Once you've submitted the form, you then use that data to loop through the
posted data, so something like (pseduo, untested code)
foreach($i=0, $i<$_POST['foundCount'], $i++) {
$updateRecord->NewFX etc etc
$updateRecord->AddDBParam('-recid',$_POST['-recID'][$i])
$updateRecord->AddDBParam('dataOne',$_POST['dataOne'][$i])
$updateRecord->AddDBParam('dataTwo',$_POST['dataTwo'][$i])
// etc etc
}
I'm not in a position to build you a working demo just now, but I have
code that does exactly this I can send you later in the day if you can't
get it to work ;-)
Cheers
Steve
When you submit the form
> Rob,
>
> Have you considered batching up the data for the multiple edits,
> sending the data to FileMaker and then running a looping script to
> edit them all at one time?
>
> Jonathan
>
>
> At 12:38 PM +0200 8/9/06, robhelleshoj at tiscali.dk wrote:
> >Hi,
> >Is there a fast way to edit mutiple records?
> >I have a list of records, which at the moment can be edited one at a
> >time. There
> >is a pop-up list in a form and a corresponding submitbutton on each
> >record. The
> >user changes the value of the popup and then submits.
> >
> >What the user wants though is to be able to change several pop-ups in
> the list
> >and then submit wit one singe button, since this reduces waiting time
> between
> >the changes.
> >
> >The list is made with a foreach loop, where the form is within the
> >loop and thus
> >repeated for each record. The records are at the moment changed one at
> a time
> >based on the recordID and the list is then updated. This takes a
> couple of
> >seconds for each update.
> >
> >I have unsuccesfully been trying to figure out how to collect the
> >content of the
> >form on each record into one post variable for the whole list. The
> >idea is then
> >to do a foreach loop on the actual edit-page, where the data in the
> >corresponding field on the corresponding record is changed, and where
> another
> >field - a log - is changed also.
> >
> >If the for each loop is within the form I ought to get a list of
> >pop-ups all in
> >the same form with one submit for the whole list. I still need a
> secure way to
> >relate this field to the recordID of that specific record (a hidden
> >field in the
> >form), but the resulting array should be sent to the edit page and
> then the
> >changes are made one record at a time in a loop. This should reduce
> >the waiting
> > time between the single changes.
> >
> >I am working on this, and do not have the complete code ready yet. I
> >am open to
> >suggestions on how to get this working.
> >
> >
> >_______________________________________________
> >FX.php_List mailing list
> >FX.php_List at mail.iviking.org
> >http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
> --
>
> Jonathan Schwartz
> Schwartz & Company
> jonathan at eschwartz.com
> http://www.eschwartz.com
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
More information about the FX.php_List
mailing list