0

I parse from MYSQL into checkbox with foreach. But I want to get checked checkbox value from that foreach checkbox. So I could parse another record from MYSQL with this checked values.

I'm using CodeIgniter

<?php foreach($tb_pertanyaan->result() as $row): ?>
    <fieldset id="<?php echo $row->kode_pertanyaan; ?>">
        <h6 style="text-indent :2em;"><input type="checkbox" name="kode_pertanyaan" value="<?php echo $row->kode_pertanyaan; ?>"> <?php echo $row->pertanyaan; ?><br> </h6>
    </fieldset>
<?php endforeach;?>
Bosco
  • 1,536
  • 2
  • 13
  • 25

1 Answers1

1

You could just change name="kode_pertanyaan" to name="kode_pertanyaan[]" on your html form.
Then you sould get the records using selection method such as where_in() :

$kode_pertanyaan = $this->input->post('kode_pertanyaan');
$this->db->where_in('column_name', $kode_pertanyaan); // column_name is the column you want to fetch
$this->db->get('table_name');
Hasta Dhana
  • 4,699
  • 7
  • 17
  • 26