我想将多个家庭成员详细信息放在数据库中 但是插件不起作用,并且没有显示任何错误。
我已经尝试过:<input type="text" name="family_member_first_name[]" class="form-control"/>
但它没有用。
PHP:
if (isset($_POST["submit4"])) {
if ($_SESSION['email']) {
$db->where('primary_email', $_SESSION['email']);
$email_fetch_femily = $db->getone('om_user_list_a');
if ($email_fetch_femily) {
$fetch_id_family = $email_fetch_femily['id'];
}
$status = 1;
$c_by = 1;
$c_date = date('Y-m-d H:i:s');
$c_ip = $_SERVER['REMOTE_ADDR'];
$row = $_POST['num'];
for ($i = 0; $i < $row; $i++) {
$insert_family_details = $mysqli->query("INSERT into `om_relative_list` (`user_id`,`first_name`,`middle_name`,`last_name`,`birth_date`,`relative_type`,`marital_status`,`education_status`,`occupation`,`phone`,`gratuity_ratio`,`nomination_ratio`,`status`,`created_by`,`created_date`,`created_ip`) values ('$fetch_id_family','" . $_POST['family_member_first_name'][$i] . "','" . $_POST['family_member_middle_name'][$i] . "','" . $_POST['family_member_last_name'][$i] . "','" . $_POST['family_member_birth_date'][$i] . "','" . $_POST['family_member_relation'][$i] . "','" . $_POST['family_member_merital_status'][$i] . "','" . $_POST['family_member_education'][$i] . "','" . $_POST['family_member_occupation'][$i] . "','" . $_POST['family_member_phone'][$i] . "','" . $_POST['family_member_gratuity_ratio'][$i] . "','" . $_POST['family_member_nomination_ratio'][$i] . "','$status','$c_by','$c_date','$c_ip')");
}
if ($insert_family_details) {
echo "<script>alert('family details insert successfully');</script>";
} else {
echo "<script>alert('!!!!family deatis insert unsuccessfully');</script>";
}
}
}
HTML:
<div class="row clearfix">
<div class="col-sm-9">
<div class="form-group form-group-default">
<label><font size="2">HOW MANY MEMBER IN YOUR FAMILY ?</font></label>
<input type="text" name="family_member" class="form-control"/>
</div>
</div>
<div class="col-sm-3">
<button type="submit" name="family_member_btn" class="btn btn-lg btn-info" style="padding:11pt;width:200px;"/>
<span><b><font size="2">SUBMIT</font></b></span></button>
</div>
</div><br><br>
<?php
for($i = 1; $i <= $family_member; $i++) {
?>
<input type="hidden" value="<?php echo $family_member;?>" name="num">
<div class="row clearfix">
<div class="col-sm-4">
<div class="form-group form-group-default">
<label><font size="2">First Name</font></label>
<input type="text" name="family_member_first_name[]" class="form-control"/>
</div>
</div>
<div class="col-sm-4">
<div class="form-group form-group-default ">
<label><font size="2">Middle Name</font></label>
<input type="text" name="family_member_middle_name[]" class="form-control">
</div>
</div>
<div class="col-sm-4">
<div class="form-group form-group-default ">
<label><font size="2">Last name</font></label>
<input type="text" name="family_member_last_name[]" class="form-control"/>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4">
<div class="form-group form-group-default ">
<label><font size="2">birthdate</font></label>
<input id="datepicker3" class="form-control" name="family_member_birth_date[]" type="text"/>
</div>
</div>
<div class="col-sm-4">
<div class="form-group form-group-default form-group-default-selectFx">
<label><font size="2">Realation</font></label>
<select class="cs-select cs-skin-slide cs-transparent form-control" name="family_member_relation[]" data-init-plugin="cs-select">
<option value=""></option>
<?php
$db->where('type_id','4');
$Industry = $db->get('om_master_values');
foreach ($Industry as $indu) {
?>
<option value="<?php=$indu['id']?>"><?php=$indu['master_values']?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-sm-4">
<div class="form-group form-group-default form-group-default-selectFx">
<label><font size="2">MARITAL STATUS</font></label>
<select class="cs-select cs-skin-slide cs-transparent form-control" name="family_member_merital_status[]" data-init-plugin="cs-select">
<option value=""></option>
<option value="married">MARRIED</option>
<option value="unmarried">UNMARRIED</option>
</select>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4">
<div class="form-group form-group-default form-group-default-selectFx">
<label><font size="2">EDUCATION</font></label>
<select class="cs-select cs-skin-slide cs-transparent form-control" name="family_member_education[]" data-init-plugin="cs-select">
<option value=""></option>
<?php
$db->where('type_id','5');
$Industry = $db->get('om_master_values');
foreach($Industry as $indu){
?>
<option value="<?php echo $indu['id'] ?>"><?php echo $indu['master_values'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-sm-4">
<div class="form-group form-group-default">
<label><font size="2">occupation</font></label>
<input type="text" name="family_member_occupation[]" class="form-control"/>
</div>
</div>
<div class="col-sm-4">
<div class="form-group form-group-default">
<label><font size="2">PHONE</font></label>
<input type="text" name="family_member_phone[]" class="form-control"/>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4">
<div class="form-group form-group-default">
<label><font size="2">gratuity_ratio</font></label>
<input type="text" name="family_member_gratuity_ratio[]" class="form-control"/>
</div>
</div>
<div class="col-sm-4">
<div class="form-group form-group-default">
<label><font size="2">nomination_ratio</font></label>
<input type="text" name="family_member_nomination_ratio[]" class="form-control"/>
</div>
</div>
</div>
请帮助我,并给我更新的代码。