문제

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?

도움이 되었습니까?

해결책

If $dt is object, than you can you it as below

$dt->id_berita
$dt->tanggal
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top