<select name="mul_cat1[]" class="form-text" style="width: 85%;" >
<option value="">-Select-</option>
<option value="1">Pianoforte</option>
<option value="2">All Wind</option>
</select>
<select name="mul_cat1[]" class="form-text" style="width: 85%;" >
<option value="">-Select-</option>
<option value="1">Pianoforte</option>
<option value="2">All Wind</option>
</select>
<input name="entrytitle1[]" type="text" required />
<input name="entrytitle1[]" type="text" required />
<input name="composer1[]" type="text" required/>
第一个条目的结尾
开始第二个条目
<select name="mul_cat1[]" class="form-text" style="width: 85%;" >
<option value="">-Select-</option>
<option value="1">Pianoforte</option>
<option value="2">All Wind</option>
</select>
<select name="mul_cat1[]" class="form-text" style="width: 85%;" >
<option value="">-Select-</option>
<option value="1">Pianoforte</option>
<option value="2">All Wind</option>
</select>
<input name="entrytitle1[]" type="text" required />
<input name="entrytitle1[]" type="text" required />
<input name="composer1[]" type="text" required/>
我现在要做的是知道如何捕获数据并将其推送到mysql数据库。所以必须将mul_cat1推入不同行的表中,而且entrytitle必须与mulcat尊重。
所以Mysql数据库中的输出将如下所示:
id | mul_cat1 | entrytitle1 | composer1
1 | 1 | milk | John
2 | 2 | water | John
3 | 2 | dance | Mark
4 | 1 | sing | Mark
这就是我正在使用但它不起作用
$data2=array();
for($x=0,$l=count($entrytitle1); $x<$l; $x++){
$muldata=implode(',', $mul_cat1);
echo $muldata;
$myArray2 = explode(',', $entrytitle1[$x]);// you can use your own filter for names
$myArray3 = explode(',', $muldata[$x]);// you can use your own filter for names
foreach (array_combine($myArray2, $myArray3) as $title => $mul) {
$data2[]='("'.trim($title).'", "'.trim($mul).'", "'.$_SESSION['id'].'", 2, "'.$entry_id.'")';
}
}
$query="INSERT INTO multiple_category (title_of_entry, multiple_cat,con_registration_idcon_registration, acts_idacts, entry_id) VALUES".implode(',',$data2);
$result = mysqli_query($dbc, $query);