I am trying to insert the data in PHP with the array keys wise. I know how to insert data function when if data is single and without array. but this is an issue is comes first in my beginning PHP. I have seen the other post with the `implode function but I couldn't understand that.
I am trying if product 123456 the QTY will insert 100 AND if product 123654 the QTY will 150 and other data will constantly insert.
DATABASE STRUCTURE
---------------------------------------------------------------------------
| ID | SKU | PRODUCT | QTY | SUBJECT | ANY_COMMENT |
---------------------------------------------------------------------------
| 1 | 106101 | 123456 | 100 | MY TEST SUBJECT | MY_COMMENT |
---------------------------------------------------------------------------
| 2 | 106101 | 123654 | 150 | MY TEST SUBJECT | MY_COMMENT |
---------------------------------------------------------------------------
PHP ARRAY
Array
(
[subject] => MY TEST SUBJECT
[sku] => 106101
[product] => Array
(
[0] => 123456
[1] => 123654
)
[qty] => Array
(
[0] => 100
[1] => 150
)
[comment] =>MY_COMMENT
)
PHP CODE
$stmt = $con->prepare("INSERT INTO `table` SET(`SKU`, `PRODUCT`, `QTY`, `SUBJECT`, `ANY_COMMENT`) VALUES(:sku, :product, :qty, :subject, :comment)");
$stmt->execute();