陷入codeigniter代码,复选框数组,
查看代码:
<input type="checkbox" name="company_type[]" value="Exporter" class="get_value"> Exporter
<input type="checkbox" name="company_type[]" value="Importer" class="get_value"> Importer
<input type="checkbox" name="company_type[]" value="Distributor" class="get_value"> Distributor
<?php
foreach($form as $company_type)
{
echo $company_type = implode(",",$company_type);
}
?>
================================= 模型方法:
public function save_registration_form($post)
{
return $this->db->insert('members', [ 'company_type' =>$post['company_type']]);
}
=========================================== 控制器代码:
if ($this->form_validation->run() ) {
$this->model->form ($this->input->post() ) ;
========================== 代码显示问题,请帮忙解决这个问题
答案 0 :(得分:1)
你必须像这样查找你的代码
<input type="checkbox" name="company_type[]" value="Exporter" class="get_value"> Exporter
<input type="checkbox" name="company_type[]" value="Importer" class="get_value"> Importer
<input type="checkbox" name="company_type[]" value="Distributor" class="get_value"> Distributor
型号代码
public function save_registration_form($post){
$company_type = implode(",",$post['company_type']);
return $this->db->insert('members', ['company_type' =>$company_type]);
}