NEED HELP ABOUT count_all_results() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: NEED HELP ABOUT count_all_results() (/showthread.php?tid=57404) |
NEED HELP ABOUT count_all_results() - El Forum - 03-12-2013 [eluser]erviando[/eluser] i want show result of count from model to view but there is a notice "Message: Array to string conversion" please help me... thanks before... Model: function get_all_topikdo_jumlah() { $this->db->select('topik_pembimbing1'); $this->db->select('topik_pembimbing2'); $this->db->count_all_results('topik'); $this->db->from('topik'); $this->db->from('dosen'); $this->db->where('dosen_id','topik_pembimbing1'); $this->db->or_where('dosen_id','topik_pembimbing2'); $data=$this->db->get(); return $data->result(); } Controller: $data['jumlah'] = $this->topikdo_model->get_all_topikdo_jumlah(); View: <?php $no=1; foreach($daftardosen as $row) { ?> <tr> <td><?php echo $row->dosen_id;?></td> <td><?php echo $row->dosen_nama;?></td> <td><?php echo $jumlah;?></td> </tr> <?php $no++; } ?> NEED HELP ABOUT count_all_results() - El Forum - 03-12-2013 [eluser]TheFuzzy0ne[/eluser] Code: if ( ! $code_tags) First of all, how about (Ooh look! Code tags! ): Model: Code: function get_all_topikdo_jumlah() $data['jumlah'] is an array of objects, which is why echoing that is causing an error. What is this variable for? I don't understand. If you're expecting it to contain a string, you need to extract that from the database result. Also, if you're only expecting a single row, it would make sense to limit your query to a single result, and use result_row() instead of result() |