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
Post a Comment