How To Filter Data In Codeigniter
<p>i have a problem with my code , i want to filter by in 2 category . but in the work i did , just filter with one category can work , and filter with other category didnt work. anyone can help me to solve this ?</p>

<p>and this is my controller </p>

<pre><code>public function index($state = null , $category = null)
{
    if (!empty($state)) {
    $this-&gt;load-&gt;model('M_kegiatan');
    $data['username'] = $this-&gt;session-&gt;userdata('username');
    $data['kegiatan'] = $this-&gt;M_kegiatan-&gt;get_status($state);
    $this-&gt;load-&gt;view('beranda', $data); 
    }else if (!empty($category)) { 
    $this-&gt;load-&gt;model('M_kegiatan');
    $data['username'] = $this-&gt;session-&gt;userdata('username');
    $data['kegiatan'] = $this-&gt;M_kegiatan-&gt;get_kategori($category);
    $this-&gt;load-&gt;view('beranda', $data);
} else {

    $this-&gt;load-&gt;model('M_kegiatan');
    $data['username'] = $this-&gt;session-&gt;userdata('username');
    $data['kegiatan'] = $this-&gt;M_kegiatan-&gt;get_kegiatan();
    $this-&gt;load-&gt;view('beranda', $data);
}
</code></pre>

<p>this is my model :</p>

<pre><code>    public function get_status($status) {
    $this-&gt;db-&gt;order_by('tanggal','desc');
    $this-&gt;db-&gt;where('status',$status);
    $query = $this-&gt;db-&gt;get('kegiatan');

    if ($query-&gt;num_rows() &gt; 0) {
        return $query -&gt; result();
    }
}
    public function get_kategori ($kategori) {
    $this-&gt;db-&gt;order_by('tanggal','desc');
    $this-&gt;db-&gt;where('kategori',$kategori);
    $query = $this-&gt;db-&gt;get('kegiatan');

    if ($query-&gt;num_rows() &gt; 0) {
        return $query -&gt; result();
    }
}
</code></pre>

<p>from this code , just filter by get_status () can work , anyone can help me ?</p>