When I loop through Rice form variables at php end. everything work well.
<input class="rice" type="text" name="rice[]" >
<input class="beans" type="text" name="beans[]" >
<input class="price" type="text" name="price[]" >
// pdo connection
foreach($_POST['rice'] as $index => $value) {
$statement= $db->prepare('INSERT INTO product(rice)values(:rice)');
$statement->execute(array(':rice' => $value));
}
now how do I loop through beans and price as well and then insert the three products, rice, beans and price into database.
// pdo connection
foreach($_POST['rice'] as $index => $value) {
$statement= $db->prepare('INSERT INTO product(rice,beans,price)values(:rice,:beans,:price)');
$statement->execute(array(':rice' => $value,':beans'=>$value2,':price'=>$value3));
}