title: How can we count the number of active records using a specific id in codeigniter?
body: <p>I want to get the count of active records by using a specific id , i tried using this code but i did not get proper output.</p>
  
  <pre><code>    public function package_category_listing()
  {   
  
      $query = $this-&gt;db-&gt;get("mn_package_category");
      $data['records'] = $query-&gt;result();
      foreach($data['records'] as $r)
      {
      $c=$r-&gt;category_id;
  
      }
      $query = $this-&gt;db-&gt;query('SELECT * FROM mn_package WHERE `category_id` = '.$c);
      $data['data']= $query-&gt;num_rows();
      $this-&gt;load-&gt;view('admin/package/package_category_listing',$data );
  }
  </code></pre>