• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NEED HELP ABOUT count_all_results()

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...

function get_all_topikdo_jumlah()

return $data->result();

$data['jumlah'] = $this->topikdo_model->get_all_topikdo_jumlah();


foreach($daftardosen as $row)
<td>&lt;?php echo $row->dosen_id;?&gt;</td>
<td>&lt;?php echo $row->dosen_nama;?&gt;</td>
<td>&lt;?php echo $jumlah;?&gt;</td>
&lt;?php $no++;

if ( ! $code_tags)
    echo 'Behold the power of the [code] tags!';

First of all, how about (Ooh look! Code tags! Big Grin):

function get_all_topikdo_jumlah()
   // No point doing this unless we're assigning the number of results to a variable.
  $data['total_rows'] = $this->db->count_all_results(‘topik’);

  $data['results'] = $this->db->get()->result();

  return $data;

$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()

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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