I'm getting an error:
Parse error: syntax error, unexpected '"', expecting ']' at the line - '$_POST[ingredientAMT" . $i . "]',
I have the following code:
for ($i=1; $i<=$_POST[ingre_amt]; $i++)
{
$SQL1 = "INSERT INTO
recipeingredients (MealID, IngreAmt, UnitID, IngreID)
VALUES (
'$_POST[mealID]',
'$_POST[ingredientAMT" . $i . "]',
'$_POST[ingredientUNIT" . $i . "]',
'$_POST[ingredientNAME" . $i . "]')";
}
I also tried.....
for ($i=1; $i<=$_POST[ingre_amt]; $i++)
{
$SQL1 = "INSERT INTO
recipeingredients (MealID, IngreAmt, UnitID, IngreID)
VALUES (
'$_POST[mealID]',
'$_POST[ingredientAMT";
$SQL1 .= $i;
$SQL1 .= "]', '$_POST[ingredientUNIT";
$SQL1 .= $i;
$SQL1 .= "]', '$_POST[ingredientNAME";
$SQL1 .= $i;
$SQL1 .= "]')";
}
I don't know how many ingredient will be inputted, so I need to have $i go in there.
Here is the HTML code if you need to look at it
<form action="recipe_info_post.php" method="post">
<?php
if (isset($NumIngred))
{
for ($i=1; $i<=$NumIngred; $i++)
{
echo "<tr>";
echo "<td> <input type='text' name='ingredientAMT" . $i . "' size=1 /></td>";
echo "<td><select name='ingredientUNIT" . $i . "'><option>" . $unit_options . "</option></select> </td>";
echo "<td><select name='ingredientNAME" . $i . "'><option>" . $ingre_options . "</option></select> </td>";
echo "</tr>";
}
}
?>