[eluser]jacobson[/eluser]
Hello I have a problem with "passing" the number of records (count(*))
I have a model:
Code:
$this->db->select('value1');
$this->db->group_by('value1');
$q = $this->db->get(TBL_1);
$result = $q->result();
if(!$result || ($q->num_rows() < 0)){
echo "Error";
return;
}
if($q->num_rows() == 0){
return;
}
return $result;
My controller passes the informations to the view which looks like:
Code:
<table border="1px">
<?php
foreach($records as $row) {
echo "<tr><td>" . $row->value1 . "</td><td>" . $this->db->count_results($row->value1) . "</td></tr>";
}
?>
</table>
In the place where I "try" to count results in the view i want to have the number of records where the field is equal to "value1".
I'm quite sure that I'm doing something wrong and that I should cound those values in my model. But my controller :
Code:
$this->load->model('data_selection_model');
$data['records'] = $this->data_selection_model->display_data_number();
assigns to $records the value of $result from the model which stores the value1. I tried at first making in model select ('value1', 'count(*)') but in the view there appears the problem. i can do $row->value1 but I cant do $row->count(*).
I hope someone could help me with this problem