lundi 1 mai 2017

Show data from multiple checkbox in codeigniter

i hope all of you can help me to solve my application problem

my problem is when i would like to show data from my multiple checkbox , data success to show but just showing my first data that i have check. example is i check data 1 , data 2 , data 3, but the only data 1 are showing on my page.

my controller :

function comparison()
    {
        if ($this->input->post('submit')) {
            foreach ($id_product = $this->input->post('id_product') as $rm) {
                $show_compare = $this->Compare->start_compare($rm);
            }
            $data['comparison'] = $show_compare;
            $data['title'] = "Comparison";
            $data['meta_keywords'] = ". . .";
            $data['meta_descriptions'] = ". . .";
            $this->load->view('theme/comparison',$data);
        }
    }

My Model :

function start_compare($id_product)
    {
        $this->db->select('product.id_subcategory,product.type,product.product_name,specificcategory.specificcategory_name,specification_biostar.*');
        $this->db->join('specification_biostar', 'specification_biostar.id_product = product.id_product', 'left');
        $this->db->join('specificcategory', 'specificcategory.id_specificcategory = product.id_subcategory', 'left');
        $this->db->where('product.id_product', $id_product);
        $sql = $this->db->get('product')->result_array();
        return $sql;
    }

my view (option multiple-checkbox) :

<div class="box-body">
     <input type="checkbox" name="id_product[]" id="txt" onClick="EnableSubmit3(this)" value="<?php echo $row['id_product']; ?>"><label>Choose</label>
     </div>

my view (result data) :

 <table class="table">
                <?php foreach ($comparison as $row){ ?>
                <tr>
                    <td colspan="2"><?php echo $row['id_product'] ?></td>
                </tr>
                <?php } ?>
            </table>




Aucun commentaire:

Enregistrer un commentaire