Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14346

struggling with foreach using checkbox values

$
0
0
Please i'm stucked with this problem for an hour now(yeah i'm newbie in this).

this is a piece of code in my controller


PHP Code:
$tags $this->input->post('check_list');
 
           
            
            foreach
($tags as $t){
 
               
                $q 
$this->db->get_where('info', array('text_id' => $t))->result()->text_name;
 
               //$data['q'] = $this->db->get_where('info', array('text_id' => $t))->result()->text_name;
 
               
                $data
['qe'] = $q.' ,';
 
           

and this is the view(index.php). i also wanted to see the query i did,so tried to output it with last_query() :
PHP Code:
<?php
    
echo form_open();
    
?>

<input type="checkbox" name="check_list[]" value="1">love<br>
<input type="checkbox" name="check_list[]" value="2">heart<br>
<input type="checkbox" name="check_list[]" value="3">heaven<br>
<input type="checkbox" name="check_list[]" value="4">sun<br>
<input type="checkbox" name="check_list[]" value="5">earth<br>
    
        <?php
    
echo form_submit('''Save');
    echo 
form_close();
    
?>
    
    <div>The Checked boxes names were: 

<?php echo $qe;
    
var_dump($qe);
    
var_dump($this->db->last_query());
    
?></div>
     

and the printed result is:
Code:
,string(2) " ," string(4) "SELECT * FROM `info` WHERE `text_id` = '4'"

what i want to achieve is something like this depending on the selected checbox by their id:
The Checked boxes names were: sun, heaven, earth

Viewing all articles
Browse latest Browse all 14346

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>