我尝试使用codegniter插入多个相同的输入字段名称。但仍然无法插入,请尝试帮助解决我的问题
<script>
$(document).ready(function () {
$("#hide").click(function () {
$("#hideshow").show();
});
$("#show").click(function () {
$("#hideshow").hide();
});
});
</script>
<script>
$(document).ready(function () {
$("#my_select_rooms").change(function () {
$('.divcls').html('');
var id = $(this).val();
for (var i = 0; i < id; i++) {
$('.divcls').append('<div class="row">' +
'<div class="col-sm-3 form-group">' +
'<label>Guest for room ' + (i + 1) + '</label>' +
'</div>' +
'<div class="col-sm-3 form-group">' +
'<label class="form-group">Adults</label>' +
'<select name="fldCustomerFormPaxRoomsAdult[]" class="col-sm-3 form-group form-control show-menu-arrow">' +
'<option value="1">1</option>' +
'<option value="2" selected>2</option>' +
'<option value="3">3</option>' +
'<option value="4">4</option>' +
'<option value="5">5</option>' +
' </select>' +
'</div>' +
'<div class="col-sm-3 form-group">' +
'<label class="form-group">Child</label>' +
'<select name="fldCustomerFormPaxRoomsChild[]" class="form-group form-control">' +
'<option value="0" selected>0</option>' +
'<option value="1">1</option>' +
'<option value="2">2</option>' +
'<option value="3">3</option>' +
'<option value="4">4</option>' +
'</select>' +
'</div>' +
'<div class="col-sm-3 form-group">' +
'<label class="form-group">infant</label>' +
'<select name="fldCustomerFormPaxRoomsInfant[]" class="form-group form-control">' +
'<option value="0" selected>0</option>' +
'<option value="1">1</option>' +
'<option value="2">2</option>' +
'<option value="3">3</option>' +
'<option value="4">4</option>' +
'</select>' +
'</div>' +
'</div>');
}
});
});
</script>
$fldCustomerFormPaxRoomsAdult = $this->input->post('fldCustomerFormPaxRoomsAdult');
$fldCustomerFormPaxRoomsChild = $this->input->post('fldCustomerFormPaxRoomsChild');
$fldCustomerFormPaxRoomsInfant = $this->input->post('fldCustomerFormPaxRoomsInfant');
$count = $this->input->post('my_select_rooms');
for ($x = 0; $x < sizeof($count); $x++) {
$data5 = array(
'fldCustomerID' => $fldCustomerID,
'fldCustomerFormPaxRoomsAdult' => $fldCustomerFormPaxRoomsAdult[$x],
'fldCustomerFormPaxRoomsChild' => $fldCustomerFormPaxRoomsChild[$x],
'fldCustomerFormPaxRoomsInfant' => $fldCustomerFormPaxRoomsInfant[$x]
);
}
var_dump($data5);die;
$this->db->insert_batch('product_pricing', $data5);
我想附加所有输入字段数据