I'm trying to insert multiple rows of form data into db, the number of items is determined by the user:
for ($i=0; $i < count($appItem); $i++) {
$sql = "
INSERT $table_name
SET id='', item='$appItem[$i]',description='$appItemDesc[$i]', price='$appItemPrice[$i]'
";
}
My problem is that this is only inserting the LAST elements from the array. In other words, it's looping through the correct number of times, but only inserting the data from the last iteration of the loop. Do I need to nest the for loop inside the sql statement?