vendredi 12 juillet 2019

How to get value from checkbox and post array in codeigniter?

How to get value form multiples checkbox and post array in codeigniter? I have problem when I get value post array and echo the value. I see only the value of the last checked checkbox. How to show post value when submit?

In View Page:

<?php foreach ($menu_links as $item): ?>                                
                           <input type="checkbox" name="subcat_recip_id[]" class="square-purple" value="<?php echo html_escape($item["title"]); ?>"> &nbsp; <?php echo html_escape($item["title"]) ?>
        <?php endforeach; ?>

In controller function:

public function input_values()
{
    $data = array(
        'lang_id' => $this->input->post('lang_id', true),
        'title' => $this->input->post('title', true),
        'slug' => $this->input->post('slug', true),
        'page_description' => $this->input->post('page_description', true),
        'page_keywords' => $this->input->post('page_keywords', true),
        'page_content' => $this->input->post('page_content', false),
        'parent_id' => $this->input->post('parent_id', true),
        'page_active' => $this->input->post('page_active', true),
        'title_active' => $this->input->post('title_active', true),
        'breadcrumb_active' => $this->input->post('breadcrumb_active', true),
        'need_auth' => $this->input->post('need_auth', true),
        'howmany_people' => $this->input->post('howmany_people', true),
        'difficulty' => $this->input->post('difficulty', true),
        'howmany_time' => $this->input->post('howmany_time', true),
        'location' => $this->input->post('location', true),
        'subcat_recip_id' => $this->input->post('subcat_recip_id')
    for ($i=0; $i<count($menu_links); $i++) 
   {
    echo $subcat_recip_id[$i];
   } 
    );  
    return $data;
}




Aucun commentaire:

Enregistrer un commentaire