tb_stock:
+------------+--------------+-------------+------------+ | id_stock | name_stock | brand_id | price | +------------------------------------------------------+ | 1 | iPhone XS | 1 | 1299 | | 2 | galaxy s10 | 2 | 1000 | | 3 | galaxy s10+ | 2 | 1100 | | 4 | IWatch | 1 | 500 | +------------------------------------------------------+ From table above, i want to show only one brand in my checkbox loop. I have used foreach to get the value. But i got all of the brand in my checkbox. what i want is show only one brand and loop it.
controller:
public function index(){ $data['getStok'] = $this->M_input->getStok(); this->page->view('product', $data); } model:
public function getStok(){ $query = $this->db->get('tb_stok'); return $query->result(); } view:
<?php if(count($getStok)):?> <?php foreach ($getStok as $a):?> <div class="form-group"> <div class="col-sm-12"> <input type="checkbox" class="minimal" id="<?php echo $a->name_stok;?>" value=<?php echo $a->price;?>> <label><?php echo $a->name_stok;?></label> </div> </div> <?php endforeach;?> <?php else :?> <?php endif ;?>
what i want is show only one brand and loop it.means?