jeudi 20 décembre 2018

checkbox data not insert in mysql using codeigniter

I try to insert my checkbox data in CodeIgniter. but data did not inserted in the database. here is my view file:

  <input type="checkbox" name="feature[]" value="WIFI" >
  <input type="checkbox" name="feature[]" value="TV">

I am trying to use implode to convert the array into the string, but then I don't how to add in $data array, so they inserted in together

here is my controller:

     public function save()
     {
       $this->load->model('Partner_model');
       $feature = $this->input->post('feature');
      $fea=array(
             'feature'=>json_encode(implode(",",$feature)) 
                   );

      $user_data= array(
     'pname' => $this->input->post('pname'),
     'type' => $this->input->post('type'),
     'address' => $this->input->post('address'),
     'about' => $this->input->post('about'),
     'city' => $this->input->post('city'),
      'code' => $this->input->post('code')
     );
    if($this->Partner_model->save($user_data,$fea))
   {
       $msg = "save sucesss" ;
   }
   else
   {
       $msg = "not save";
   }

   $this->session->set_flashdata('msg', $msg);
   $this->load->view('partner_profile');
 }

& here is my model:

 public function save($data,$fea)
  {
     return $this->db->insert('property', $data,$fea);
  }




Aucun commentaire:

Enregistrer un commentaire