Forms 循环通过所有特定表单字段
我正在制作一个配方表单,其中有许多字段需要配方成分。 例如,我的代码是这样的Forms 循环通过所有特定表单字段,forms,Forms,我正在制作一个配方表单,其中有许多字段需要配方成分。 例如,我的代码是这样的 <legend><span>Recipe Ingredients</span></legend> <label for="recipe_ing" title="Ingredients Name" class="required">Ingredient:<span>*</span>&
<legend><span>Recipe Ingredients</span></legend>
<label for="recipe_ing" title="Ingredients Name" class="required">Ingredient:<span>*</span></label>
<input name="recipe_ingr" id="recipe_ingr" size="10" />
Quantity: <input id="recipe_qty" name="recipe_qty" size="5" />
unit: <input id="recipe_unit" name="recipe_unit" size="5" />
Notes: <input type="text" id="recipe_notes" name="recipe_notes" size="15" /> <br /><br />
<label for="recipe_ing" title="Ingredients Name" class="required">Ingredient2:<span>*</span></label>
<input name="recipe_ingr2" id="recipe_ingr" size="10" />
Quantity: <input id="recipe_qty" name="recipe_qty2" size="5" />
unit: <input id="recipe_unit" name="recipe_unit2" size="5" />
Notes: <input type="text" id="recipe_notes" name="recipe_notes2" size="15" /> <br /><br />
配方成分
成分:*
数量:
单位:
注:
Ingredient2:*
数量:
单位:
注:
它最多有15种成分、数量、单位和注释
表单数据由formcheck.php处理和控制
现在的问题或我的问题是,formcheck.php中可能的选项/函数是什么?这样,我就不用定义15次if(isset($\u POST[]),而是运行一个循环,它会获取配料、数量、单位和注释的所有相关数据
我希望我能说清楚如果您在不同的表单字段中漏掉数字会怎么样? 因此,创建15个“配方”字段。在perl中,您得到一个包含所有值的变量
或者在1到15之间做一个for循环?我可以做任何必要的更改,我可以把它们都做出来。由于我对php了解不多,那么循环遍历所有值的正确循环函数是什么呢?我也不知道php,但也许这可以帮助您: