Friday, 15 May 2015

php - Nested foreach loop issue -


I'm trying to get this nested foreach loop to work, but I have no luck have been found . This is my code.

  $ q = 0; $ ArrayCountTwo = Counting ($ _ POST ['Quantity']); $ I = 0; $ ArrayCountThree = Counting ($ _ POST ['item']); Foreign currency ($ _POST ['items'] as $ item) {$ sql = ''; Foreign Currency ($ _POST ['Quantity'] as the $ quantity) {$ q ++; If ($ q> $ arrayCountTwo) {break; } And {$ sql. = "INSERT_trade_show_restrated` (product ID, dated, date-protected, quantified protected) value (''. $ Item. '', ''. $ StartDate. '', ''. $ EndDate." ',' '. $ Quantity. ')';} Var_dump ($ sql);}}   

This gives me the first value in the $ items array on each recurring

Here are the arrays to be requested by you.

Objects and quantity order order.

  array (3) {[0] = & gt; String (2) "11" [1] => String (1) "6" [2] = & gt; String (1) "2"} array (3) {[0] => string (1) "1" [1] => string (1) "2" [2] = & gt; string 1) "1"}   

should do this every time.

  INSERT in `ts_table` (productivity, dated, date-protected, quantity, safe values ('11', '2013-4-11', '2013-4-25', '1') INSERT `ts_table` (productivity, date, reserve, date reserved, quantity, protected) value ('6', ' 2013 - 4-11 ',' 2013-4-25 ',' 2 ')    

< P> This should do you:
  foreach ($ _POST ['items'] as $ key = & g T; $ Item) {$ sql = "INSERT IN_trade_show_reserved_ (Product ID, Dated, Values ​​(Reserved), Quantity (Reserved) Value (''. $ Items. '', ''. $ StartDate. '', '. $ EndDate.' ',' ". $ _ POST ['Quantity]] [$ of].") "; $ Sql ​​per second" & lt; br & gt;';}    < / Html>

No comments:

Post a Comment