php - Multidimensional Array for making 2 sql update query -
edit: adjusted array understand easyer.
i'm struggling couple of days , drives me crazy...
what want 2 sql update queries this. note statement array.
code:
"update gewasregistratie set lengtegroei= 1, vruchten_geaborteerd= 1, etc.. kenmerk = 'standaard' , user_id = ".$user"" "update gewasregistratie set lengtegroei= 2, vruchten_geaborteerd= 2, etc.. kenmerk = 'natugro' , user_id = ".$user""
i got multi-level array (its $_post["type"]
array).
array ( [lengtegroei] => array ( [standaard] => 1 [natugro] => 2 ) [vruchten_geaborteerd] => array ( [standaard] => 1 [natugro] => 2 ) [plantbelasting_geteld] => array ( [standaard] => 1 [natugro] => 2 ) [uitgroeiduur] => array ( [standaard] => 1 [natugro] => 2 ) [percentage_85ers_en_95ers] => array ( [standaard] => 1 [natugro] => 2 ) [oogstfrequentie_per_week] => array ( [standaard] => 1 [natugro] => 2 ) [gezette_vruchten] => array ( [standaard] => 1 [natugro] => 2 ) [gemiddeld_vruchtgewicht] => array ( [standaard] => 1 [natugro] => 2 ) [vruchten_geoogst] => array ( [standaard] => 1 [natugro] => 2 ) [drain] => array ( [standaard] => 1 [natugro] => 2 ) )
do mean this?
<?php $aall = array(); $atogather = array( 'standaard' => array(), 'natugro' => array() ); foreach($apost $skey => $mrequest) { if(is_array($mrequest)) { foreach($mrequest $sinnkey => $mvalue)) { $atogather[$sinnkey][] = $skey . ' = ' . '"'.$mvalue.'"'; } } } foreach($atogather $skey => $mvalue) { echo 'update gewasregistratie set '.implode(', ', $atogather[$skey]).' kenmerk = "'.$skey.'" , user_id = ...'; } ?>
Comments
Post a Comment