当我想将数据插入一个字段时,我有问题。如何在多个记录中插入数据。这是我的表格。
<table>
<thead>
<th>Name</th>
<th>Age</th>
</thead>
<tr>
<td><input name="name[]" type="text" /></td>
<td><input name="age[]" type="text" /></td>
<td><input type="checkbox" name="Roles[]" value="Dealer" class="flat-red"> Dealer
<input type="checkbox" name="Roles[]" value="Runner" class="flat-red"> Runner</td>
</tr>
<tr>
<td><input name="name[]" type="text" /></td>
<td><input name="age[]" type="text" /></td>
<td><input type="checkbox" name="Roles[]" value="Dealer" class="flat-red"> Dealer
<input type="checkbox" name="Roles[]" value="Runner" class="flat-red"> Runner</td>
</tr>
<tr>
<td><input name="name[]" type="text" /></td>
<td><input name="age[]" type="text" /></td>
<td><input type="checkbox" name="Roles[]" value="Dealer" class="flat-red"> Dealer
<input type="checkbox" name="Roles[]" value="Runner" class="flat-red"> Runner</td>
</tr>
</table>
<input type="submit" name="submit" value="Submit" />
</form>
有人可以帮帮我吗? 这是我的PHP代码:
$Nameasinic = $_POST['name'];
$IDNumber = $_POST['age'];
$Roles = $_POST['Roles'];
for ($i = 0; $i < count($Nameasinic); $i++)
{
$name = $Nameasinic[$i];
$age = $IDNumber[$i];
$Roles1 = $Roles[$i];
$sql_reg = "INSERT INTO owners(`Name_as_in_IC`,`ID_No`,`Roles_Dealer`)VALUES('$name','$age','$Roles')";
$result = mysqli_query($conn, $sql_reg ) or die(mysqli_error($conn));
}
但我无法获得复选框值
答案 0 :(得分:0)
如果我理解你的话,试试这样......
obj.cells.filter(function(rm){if(rm.attrs.text.id == "vrn"){
return rm.attrs.text.text = 123
} })
console.log(obj)
在PHP代码中
<table>
<thead>
<th>Name</th>
<th>Age</th>
</thead>
<tr>
<td><input name="name[0]" type="text" /></td>
<td><input name="age[0]" type="text" /></td>
<td><input type="checkbox" name="Roles[0][]" value="Dealer" class="flat-red"> Dealer
<input type="checkbox" name="Roles[0][]" value="Runner" class="flat-red"> Runner</td>
</tr>
<tr>
<td><input name="name[1]" type="text" /></td>
<td><input name="age[1]" type="text" /></td>
<td><input type="checkbox" name="Roles[1][]" value="Dealer" class="flat-red"> Dealer
<input type="checkbox" name="Roles[1][]" value="Runner" class="flat-red"> Runner</td>
</tr>
<tr>
<td><input name="name[2]" type="text" /></td>
<td><input name="age[2]" type="text" /></td>
<td><input type="checkbox" name="Roles[2][]" value="Dealer" class="flat-red"> Dealer
<input type="checkbox" name="Roles[2][]" value="Runner" class="flat-red"> Runner</td>
</tr>
</table>
<input type="submit" name="submit" value="Submit" />
</form>