Hi,I can't display Multiple checkbox save value in my veiw page.
Here is insert/save value details:

Model
---------
public function saveInstituteOfferdCourse($data = array()) {
    if ($this->db->insert('tbl_course_offred', $data)) {
        return $this->db->insert_id();          // tbl_course_offred = "Table name"
    }
    return FALSE;
}
----------
Controller
----------
public function saveCourses() {
    $data = array();
    $this->load->library('form_validation');
    $this->form_validation->set_rules('skill', 'skill', 'require');
    if ($this->form_validation->run()) {
        $skill = implode(',', $this->input->post('skill'));
        $data['skill'] = $skill;
        $data['user_id'] = $this->session->userdata('user_id');
        $this->user_admin_model->saveInstituteOfferdCourse($data);
        redirect("user_admin_controller/showInsSkills");
    }
}
-------
view
-------
<form name="form" method="post" action="tambah">
<input type="checkbox" name="skill[]" value="PHP" >PHP</input
<input type="checkbox" name="skill[]" value="VB.NET" >VB.NET</input
<input type="checkbox" name="skill[]" value="C#" >C#</input
<input type="submit" value="Submit" />
</form>



................

I want display value like below site courses.please check the site and give me idea or code.it is very urgent hope anybody help me.
Click Here
please help me master...

Regards,

Hi,

Although I am not a master NOR I am close to becoming one and I have not seen codeIgniter for a while, I am still familiar with the basic syntax of this framework..

Before getting into this question, please allow me to ask you this..

on your controller file, did you add the load view method? example

$this->load->view('this_form', $data);

If so, on your view file called 'this_form.php', you must loop through the $data array, because it is defined as an array in your controller file..

** WARNING! codes are not tested. Please use as guidelines only if applicable.** For example,

<!-- filename: this_form.php -->
<form>
<?php 
foreach($data as $item){

   echo '<input type="checkbox" value="'.$item.'">'. $item ;
   }

   ?>
  <!-- add more form items here -->
 </form> 

In CI, you can also do this. If you can modify your codes above to something similar to this, it will be a lot easier for you to assign the values for skill as demonstraed by item1 array.

    $data = array(

            'item1' => array('item1a'=>'item1a1','item1b'=>'item1b1'),
            ## let me use data from your codes above.
            'item2' => $this->session->userdata('user_id')
            )

It is highly recommended to pass the data in this manner. By adhering to this recommendation, it will be so much easier to implement templating engine in the near future.

I think ??? CI also allows you to do this..

    public function your_function(){

    $data = array();

    return $data;
    }

    $this->load->view('this_form',self::your_function());

or

     $this->load->view('this_form', $this->your_function());

if it does, then my sample codes above is pretty nice and clean, and at the same time it is a template engine friendly .

ADDED INFO: If you are interested in twig templating engine for CI, you can download the repo here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.