Code break error

In model / rci _model.php

public function record_count() {
    return $this->db->count_all("produk");
}

    public function fetch_countries($limit, $start) {
        $this->db->limit($limit, $start);
         $query=$this->db->query("SELECT * FROM produk WHERE id_kategori='Men' order by nama_produk ASC");
            return $query->result();

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $data[] = $row;
            }
            return $data;
        }
        return false;
   }

      

In controller / sandal_clarudo.php

function sandals_for_men(){
    $data['seo'] = $this->rci_model->tampil_meta(22);
    $this->load->view('head', $data);
    $config = array();
    $config["base_url"] = "http://localhost/clarudo/index.php/sandal_clarudo/sandals_for_men/";
    $config["total_rows"] = $this->rci_model->record_count();
    $config["per_page"] = 5;
    $config["uri_segment"] = 3;

    $this->pagination->initialize($config);

    $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
    $data["results"] = $this->rci_model->
        fetch_countries($config["per_page"], $page);
    $data["links"] = $this->pagination->create_links();
    $this->load->view('men', $data);
    $this->load->view('footer');
}

      

In sight /men.php

<?php
foreach($results as $t) {
$t->nama_produk
}
<div><?php echo $links; ?></div>

      

I want to show a product that has a category = "Men" but in my code showing the whole product of a category it makes me confused, help me please.

+3


source to share


1 answer


Try to use this code for fetch_countries () function

public function fetch_countries($limit, $start) {
   $this->db->limit($limit, $start);
   $query = $this->db->query("SELECT * FROM produk WHERE id_kategori='Men' order by nama_produk ASC");
   return $query->result();
}

      



what happens here is you return results if available, or return false

0


source







All Articles