jeudi 3 septembre 2015

how to insert multiple checkbox values as successive rows in mysql codeigniter

employer_rgn.php

<div class="form-group">
  <label for="" class="control-label col-xs-2">
    <?php echo $this->lang->line('spclzd_ctgry'); ?>
  </label>
  <div class=" col-md-8">            
    <input type="checkbox" name="spec_cat[]" value="Information Technology"> Information Technology 
    <input type="checkbox" name="spec_cat[]" value="Engineering / Manufacturing">Engineering / Manufacturing <br />
    <input type="checkbox" name="spec_cat[]" value="Banking & Financial Services"> Banking & Financial Services  
    <input type="checkbox" name="spec_cat[]" value="BPO / ITES"> BPO / ITES <br />
    <input type="checkbox" name="spec_cat[]" value="FMCG / Retail"> FMCG / Retail  
    <input type="checkbox" name="spec_cat[]" value="Telecom / ISP"> Telecom / ISP <br />
    <input type="checkbox" name="spec_cat[]" value="Pharmaceuticals / Health Care"> Pharmaceuticals / Health Care  
    <input type="checkbox" name="spec_cat[]" value="Sales & Marketing"> Sales & Marketing <br />
    <input type="checkbox" name="spec_cat[]" value="Other Non IT"> Other Non IT
  </div>
</div>

employer_model

public function insert()
{
  //Insert second stage details for employer into database.
  $Specilized_category = $this->input->post('spec_cat');
  $data=array('Specilized_category'=>implode(",", $Specilized_category),);
  $this->db->insert('tbl_employer', $data);

I'm inserting check box values into database separated by commas. But the problem is, I need to get back the checked values from database in order to edit my code. How could I get those values as I had used the implode method? Or do I have to change my code for inserting values into database?




Aucun commentaire:

Enregistrer un commentaire