[FX.php List] Posting an array help

Steve Winter steve at bluecrocodile.co.nz
Mon Oct 22 09:39:35 MDT 2007


Hi William,

Umm, to my knowledge you can't use in_array to compare two arrays, you need
to loop through one of the arrays, and check the values of that array, in
the other, and then visa versa (at least that's what I'd do)

My approach would be;

foreach($v1AoE as $vlValue) {
  if(!in_array($v1Value, $medAoEData)) {
    // this means that it's in the posted array but not in the db
    // FMNew() time
  }
}

foreach($medAoEData as $medValue) {
  if(!in_array($medValue, $v1AoE)) {
    // this means that it's in the db but not the posted array
    // FMDelete() time
  }
}

Be interested to hear how others would approach this to...

Cheers
Steve

-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org
[mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of William Downs
Sent: Monday, 22 October 2007 4:28 p.m.
To: FX.php Discussion List
Subject: [FX.php List] Posting an array help

Hi there guys,

Headbanging the key board now ! Perhaps someone has already done this.

The user selects a record - this record has child records.
I allow the user to check box select any number of child records.
I then POST the array to the next page
The next page runs an FMFind for the original DB values

if there are new values in the POSTed array, they should be created
(FMNew) in the child table
If they are not in the POSTed array, it means that they have been
deselected, and should be deleted in the child table.

Here is where it falls flat - ($vlAoE is the POSTed array and
$medAoEData is the array from the DB)

if(!in_array($vlAoE,$medAoEData)) {
               //It should  create the new values here
} else {
             if(!in_array($medAoEData, $vlAoE,)) {
               //It should delete the old values here
}
}

Probably obvious what I have done wrong - but any advice more than
appreciated.

Regards

William

-- 
William Downs
Development and Support
BD Databases Ltd
_______________________________________________
FX.php_List mailing list
FX.php_List at mail.iviking.org
http://www.iviking.org/mailman/listinfo/fx.php_list

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21/10/2007
3:09 p.m.
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.488 / Virus Database: 269.15.5/1084 - Release Date: 21/10/2007
3:09 p.m.
 




More information about the FX.php_List mailing list