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;?>
4
  • can you explain more ? Commented Sep 2, 2019 at 16:24
  • share your complete code with view and controller. Commented Sep 2, 2019 at 16:33
  • stackoverflow.com/questions/4554758/… Commented Sep 2, 2019 at 17:07
  • Please explain your question. Commented Sep 3, 2019 at 5:13

1 Answer 1

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');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.