0

Im writing a filter for products, but sth went wrong

Error: A PHP Error was encountered Severity: Notice Message: Undefined variable: category

Can you please help?

Filename: product/list.php

Line Number: 41

//list.php  

         <div class="list-group">
                <h3>category</h3>
                 <?php
    foreach($category->result_array() as $row){
        ?>
                 <div clas="list-group-item checkbox">
                    <label><input type="checkbox" class="common_selector category" value="<?php echo $row['category']; ?>"> <?php echo $row['category'];?></label>
                 </div>
     <?php
    }
    ?>
             </div>
             
             
             
//Product_filter.php - controller
<?php
if (!defined('BASEPATH')) exit ('No direct script acces allowed');

class Product_filter extends CI_Controller{
    public function __construct(){
        parent::__construct();
        $his->load->model('product_filter_model');
        
    }
    function index(){
        $data['category'] = $this->product_filter_model->fetch_filter_type('category');
        
        $this->load->view('list', $data);
    }
}
?>
//Product_filter_model.php - Model
<?php
    class Product_filter_model extends CI_Model{
        function fetch_filter_type($type){
            $this->db->distinct();
            $this->db->select($type);
            $this->db->from('product');
            return $this->db->get();
            
        }
    }

?>
Yana Taranets
  • 27
  • 1
  • 8

0 Answers0