Search the Community
Showing results for tags 'multiple aray'.
-
I have two multidimensional arrays as follows: Array 01 for new prices of items: Array ( [42] => Array ( [0] => 110 [1] => 0.00 ) [41] => Array ( [0] => 80 [1] => 70.00 ) [43] => Array ( [0] => 70 [1] => 60 ) [40] => Array ( [0] => 90 [1] => 80 ) ) 1 Array 02 for old prices of items: Array ( [42] => Array ( [sales_price] => 100.00 [our_price] => 0.00 ) [41] => Array ( [sales_price] => 80.00 [our_price] => 0.00 ) ) 1 Array key of both array are item ids (42,41,43,40). Now I need to compare $new and $old arrays to create update and insert queries. If the values in the new array are different from those in the old one, the table should be updated. If there are more elements in the new array than in the old array, they should be identified for the insert query. So basically I want to divide new array into two parts with comparing old array and considering the terms above. Expecting two arrays should be as follows: Array ( [42] => Array ( [0] => 110 [1] => 0.00 ) [41] => Array ( [0] => 80 [1] => 70.00 ) ) 1 Array ( [43] => Array ( [0] => 70 [1] => 60 ) [40] => Array ( [0] => 90 [1] => 80 ) ) 1 The Code I have so far: foreach ($priceNew as $newIds => $newPrices) { foreach($priceOld as $oldIds => $oldPrices) { } }
-
I have an html form that, via javascript, depending on the user selection, appears some input fields in a row. This is the javascript: function addInputAdult(num){ inputElementsAdult.innerHTML=''; for(xAdult=0;xAdult<num;xAdult++)inputElementsAdult.innerHTML=inputElementsAdult.innerHTML +'<table width="100%" style="margin:0; padding:0;"><tr><th width="24%" scope="col">Adult '+(xAdult + 1)+' - Name</th><th width="13%" scope="col">Birthdate</th><th width="18%" scope="col">Place of Birth</th><th width="13%" scope="col">Passport Nr</th><th width="13%" scope="col">Issue Date</th><th width="16%" scope="col">Expiry Date</th></tr><tr><td> <input name="adlt[][Emri]" type="text" id="adltEmri" style="width:98%;" /></td><td> <input style="width:95%;" type="text" name="adlt[][Dtlindja]" id="adltDtlindja" /></td><td> <input style="width:90%;" type="text" name="adlt[][Vendlindja]" id="adltVendlindja" /></td><td> <input style="width:90%;" type="text" name="adlt[][Pass]" id="adltPass" /></td><td> <input style="width:90%;" type="text" name="adlt[][DtLeshimit]" id="adltDtLeshimit" /></td><td><input style="width:90%;" type="text" name="adlt[][DtSkadimit]" id="adltDtSkadimit" /></td></tr></table>'; } So, the user make the selection and the form appears. Now, i want to add the user input details in my mysql database. Can you help me on this please? I'm not "sure" how to do this. My problem is on getting the informations from the form in a way that those information could be usable and understandable. What i have tried is: foreach ( $_POST['adlt'] as $adult) { $getd=implode(",",$adult); echo $getd; } ...but it shows all the information not separated and I don't know how to separate informations from each other. Output looks like this: adult1 Nameadult1Birthdateadult1Passportadult1PlaceofBirthadult1IssueDateadult1expirydateadult2 Nameadult2 Birthdate...and so on Can you help me on this, please? Thank you in advance
- 13 replies