codeigniter - I cant get $result['query'] in my view page -


my controller erp_c:

$result['query2']= $this->erp_m->selectattend1($user,$en,$year,$month); $this->load->('salview',$result); 

in model erp_m:

function selectattend1($user,$en,$year,$month) {   $query2=$this->db->query(" select count(*) attendance3 name = '$en' , attend = 'absent' , month = '$month' , year = '$year' , user = '$user' ");  return $query2->result();   } 

in view page salview.php:

 foreach($query2 $row)  { $al=$row->count(*);///here put ,that doubt ,because $result['query']= array ( [0] => stdclass object ( [count(*)] => 1 ) ) } 

how can count value in view page?

in controller

$result['query2']= $this->erp_m->selectattend1($user,$en,$year,$month);//get data $result['count']= $this->erp_m->get_selectattend1_count($user,$en,$year,$month);//get count 

in model

function selectattend1($user,$en,$year,$month) {     $query2 = $this->db->query(" select count(*)             attendance3             name = '$en'             , attend = 'absent'             , month = '$month'             , year = '$year'             , user = '$user' ");      $result = $query2->result_array();     return $result; }  function get_selectattend1_count($user,$en,$year,$month) {     $query2 = $this->db->query(" select count(*)             attendance3             name = '$en'             , attend = 'absent'             , month = '$month'             , year = '$year'             , user = '$user' ");      $result = $query2->result_array();     $count = count($result);     return $count; } 

in view

you can access both veriables $query2 , $count

foreach($query2 $row) {     echo $row['field_name']; } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -