PHP i want to use foreach function for 3 variables i use this code in my page: $quantity){ $query = "INSERT INTO order_detail (commodity_id,quantity,c_stander_name,order_id) VALUES ('$commodity_id','$quantity','$c_stander_name','$order_id')"; $result = execute_sql($link, "0201", $query); } ?> how can i do that like : $quantity =>$c_stander_name){ $query = "INSERT INTO order_detail (commodity_id,quantity,c_stander_name,order_id) VALUES ('$commodity_id','$quantity','$c_stander_name','$order_id')"; $result = execute_sql($link, "0201", $query); } ?> No hand written and fast answer with explanation
PHP
i want to use foreach function for 3 variables
i use this code in my page:
<?php foreach(array_combine($commodity_id, $quantity) as $commodity_id => $quantity){ $query = "INSERT INTO order_detail (commodity_id,quantity,c_stander_name,order_id) VALUES ('$commodity_id','$quantity','$c_stander_name','$order_id')"; $result = execute_sql($link, "0201", $query); } ?>
how can i do that like :
<?php foreach(array_combine($commodity_id, $quantity,$c_stander_name) as $commodity_id => $quantity =>$c_stander_name){ $query = "INSERT INTO order_detail (commodity_id,quantity,c_stander_name,order_id) VALUES ('$commodity_id','$quantity','$c_stander_name','$order_id')"; $result = execute_sql($link, "0201", $query); } ?>
No hand written and fast answer with explanation
Step by step
Solved in 2 steps