这里我已经给出了多个选择的验证,即使我从选择字段中选择值并给出了提交,然后它告诉选择字段并使用codeigniter 3.0.6。搜索了很多,但找不到解决方案; 这是我的控制器
function online_booking() {
$this->form_validation->set_rules('course', 'Course', 'required');
$this->form_validation->set_rules('branch', 'Branch', 'required');
if($crs = $this->input->post('course'))
{
$course = implode(',',$crs);
var_dump($course);
}
if ($this->form_validation->run() == TRUE)
{
$this->load->model('branch_model');
$data = array('course' => $course, 'branch' => $this->input->post('branch'));
$id = $this->branch_model->insert_enquiry($data);
if ($id)
{
$this->session->set_flashdata('message', 'Booking has been Succeed,We will contact you shortly.');
redirect('online-booking');
}
else
{
$this->session->set_flashdata('message', 'Error has been occured,try again.');
redirect('online-booking');
}
}
$data['active'] = 'online';
$data['program'] = $this->home_model->get_program();
$this->load->view('online_bookin', $data);
}
这是我的观看页面
<div class="form-group col-md-6">
<label for="exampleInputEmail1">Course to be opted*</label>
<select class="form-control" name="course[]" id="course" multiple="multiple">
<option value="">Select Course</option>
<?php foreach ($program->result() as $row) if($row->parent_id !=0) {?>
<option value="<?php echo $row->id; ?>" <?php echo set_select('course',$row->id) ?> ><?php echo $row->name; ?></option>
<?php } ?>
</select>
</div>
这是我的回调函数
function is_multiple_select() {
$crs=$this->input->post('course');
if(!$crs)
{
$this->form_validation->set_message('is_multiple_select','You did not select any course to upload.');
return false;
}
else
{
return true;
}
}
这是我的模特
public function insert_enquiry($data=array())
{
if($this->db->insert(`enquiryform`,$data))
{
return $this->db->insert_id();
}
else
{
return false;
}
}
答案 0 :(得分:1)
您为什么使用此代码:
<RelativeLayout
android:id="@+id/relativelayout_root"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
删除它并检查它是否有效。或者将其放在if($crs = $this->input->post('course'))
{
$course = implode(',',$crs);
var_dump($course);
}
区块内。
答案 1 :(得分:0)
if ($this->form_validation->run() == TRUE)
{
//You can't save an array directly.
$data = array('course' => implode(",",$this->input->post('course') ), 'branch' => $this->input->post('branch') );
$this->db->insert(`enquiryform`,$data);
$insert_id = $this->db->insert_id();
}
//更改
UNION ALL
在检索爆炸的过程中它。