My php looks like this:
for ($i = 0, $count = count($ingredientQTY); $i < $count; $i++) {
$rows[] = array(
'ingredientamount' => $ingredientQTY[$i],
'ingredientType' => $measurements[$i],
'ingredientname' => $ingredientNAME[$i]
);
print_r($rows[$i]);
}
which prints out an array like this:
Array (
[ingredientamount] => 34
[ingredientType] => Centiliter
[ingredientname] => CHicken )
Array (
[ingredientamount] => 26
[ingredientType] => Grams
[ingredientname] => Cheddar Cheese )
I have three fieldnames in my database called ingredientamount, ingredientType, and ingredientname, which correspond to the two arrays which are assigned to $rows[]. So, if I had the arrays working, my database would look like this:
- ingredientamount => 34, ingredientType => Centiliter, ingredientname => Chicken
- ingredientamount => 26, ingredientType => Grams, ingredientname => Cheddar Cheese
My question is: How can I use my code to take the $rows[] (which is a multidimensional array) and insert each row into a database like mine?
Thanks for all help!
$count = count($ingredientQTY); $i < $count;instead of$i < count($ingredientQTY);?