If $dt is object, than you can you it as below
$dt->id_berita
$dt->tanggal
Pergunta
I am trying to display input in table but my code generates the following error:
Fatal error: Cannot use object of type stdClass as array in line 36
This is my view:
<tbody>
<?php
$no=1;
if ($berita){
foreach ($berita as $dt) {
echo "
<tr>
<td>$dt[id_berita]</td> (line 36)
<td>$dt[tanggal]</td>
<td>$dt[judul_berita]</td>
<td>$dt[content]</td>
<td><a class='ui tiny blue edit button' href='".base_url()."index.php/admin/berita/edit/$dt[id_berita]'><i class='edit icon'></i></a>
<a class='ui tiny blue edit button' href='".base_url()."index.php/admin/berita/delete/$dt[id_berita]'><i class='trash icon'></i></a></td>
</tr>
";
$no++;
}
}
?>
</tbody>
What is the issue with my code?
Solução
If $dt is object, than you can you it as below
$dt->id_berita
$dt->tanggal