2017-05-11 10 views
-1

in codeigniter Code stecken, Checkbox, Array,Codeigniter --- Checkbox Array Ausgabe

Ansicht Code:

<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); 
    } 

    ?> 

================== =============== Modell Methode:

public function save_registration_form($post) 
    { 
    return $this->db->insert('members', [  'company_type' =>$post['company_type']]); 
    } 

======================== ================== Controller-Code:

if ($this->form_validation->run()) { 
    $this->model->form ($this->input->post()) ; 

========================== Code zeigt Problem, bitte helfen Sie diese

Antwort

1

Sie müssen chagne Ihren Code zu lösen wie diese

<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 

Model Code

public function save_registration_form($post){ 

     $company_type = implode(",",$post['company_type']); 
     return $this->db->insert('members', ['company_type' =>$company_type]); 

    } 
+0

Thank you so much ... Ihr Code laufen –

+0

Sie begrüßen @SonalKaur –