我不知道如何解决这个脚本:在第 1 点,我需要一个 $data 数组,其中包含一种成分、数量和 um
这是html部分:
...
<tr>
<td><input name="cantitate[1]" class="cantitate" /></td>
<td><select name="unitate[1]"><?=$display->selectAmount()?></select></td>
<td><input name="ingredient[1]" class="ingredient" /></td>
</tr>
...
这是php部分:
// ingredients
$ingredients = $_POST['ingredient'];
$amount = $_POST['cantitate'];
$um = $_POST['unitate'];
foreach($_POST as $key => $value){
$data = null;
if(isset($_POST['ingredient']) && !empty($_POST['ingredient']) && $_POST['ingredient']!=''){
if($key=='cantitate') $data['amount'] = $value;
if($key=='unitate') $data['um'] = $value;
if($key=='ingredient') $data['ingredient'] = $value;
//var_dump($data);
// point 1
// here will be the function to add one ingredient with one um, and one amount
}
}
谢谢!