• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
including 3 model methods results in one controller and one view

#1
[eluser]Unknown[/eluser]
Hello i have a view with table to view all records , and its get the results form a controller which contact a model method then send results as array to the view.
controller gallery
====================
Code:
function category() //view images categories
    {
     $this->load->library('pagination');
  $this->load->model('adminme/gallery_model');
  $config['base_url'] = base_url().'index.php/adminme/gallery/category';
  $config['total_rows'] = $this->gallery_model->cat_record_count();
  $config['per_page'] = 10;
  $config['num_links'] = 5;
  $config['uri_segment'] = 4;  

  $this->pagination->initialize($config);
  
  $limit = $config['per_page'] ;
  $start = $this->uri->segment(4);
  
  $data['results'] = $this->gallery_model->cat_get_records($limit,$start);  
  $data['links'] = $this->pagination->create_links();
  $data['main_content'] = 'adminme/cat_gallery';
  $this->load->view('adminme/includes/template',$data);

Model gallery_model
===================
Code:
function cat_get_records($limit,$start)  
  {
  $this->db->limit($limit,$start);
  $this->db->select(' category_id, category_name,category_parent_id ,category_status');
  $this->db->order_by("category_name", "asc");
  $query = $this->db->get('img_g_category');  
  if($query->num_rows() > 0)
    {
    foreach ($query->result() as $row){  
    $data[] = $row;}
    
    return $data;  
    }
    else { return FALSE; }
  }

view
=====
Code:
<?php foreach($results as $item){ ?>
   <tr >
     <td>&lt;input  type="checkbox"/&gt;&lt;/td>
     <td>&lt;?php echo $item->category_id ;?&gt; </td>
     <td>&lt;?php echo $item->category_name ;?&gt;</td>
     <td>&lt;?php echo $item->category_parent_id  ;?&gt;</td>
     <td>soon</td>
     <td>&lt;?php echo $item->category_status  ;?&gt;</td>

   </tr>
     &lt;?php } ?&gt;

how can i change the value of
Code:
<td>&lt;?php echo $item->category_parent_id  ;?&gt;</td>
to get the category_name instead of category_parent_id

also how can i get the results of another model method which its:
Code:
function cat_images_record_count($id) // RETRIVE images/itesm/ COUNT for an category
{
  $query = $this->db->get_where('img_gallery', array('image_parent_id' => $id));
  $count = $query->num_rows();  
  return $count;
}
to put $count value instead of <td>soon</td> ?

i need all of them form one controller !!

please check the attached image for more understanding .

Thank you very much in advance


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.