Adem Natural Adem Natural - 5 months ago 13
SQL Question

Call to undefined function result() in Codeigniter

please help me, i've problem for get a value of database
in one page i called result() like code below :



<li><a href="#"><i class="fa fa-twitter"></i> Your Bird </a>
<ul>
<?php foreach ($burung->result() as $burung) {
echo "<li><a href=\"panels.html\">$burung->burung</a></li>";
}?>
</ul>
</li>





and next code :



<div class="row">
<?php foreach ($burung.result() as $burung) {
echo "
<div class=\"col-md-3\">
<div class=\"panel panel-default\">
<div class=\"panel-body bk-primary text-light\">
<div class=\"stat-panel text-center\">
<div class=\"stat-panel-number h1 \">24</div>
<div class=\"stat-panel-title text-uppercase\">$burung->burung</div>
</div>
</div>
<a href=\"#\" class=\"block-anchor panel-footer\">Full Detail <i class=\"fa fa-arrow-right\"></i></a>
</div>
</div>";
}?>
</div>





but the when i run this page doesn't work with message :
Call to undefined function result()

Answer

Change this

<?php foreach ($burung.result() as $burung) {

to this

<?php foreach ($burung->result_array() as $row) {

and inside code $row['burung']


Use/Change result_array() instead of result(). Read this Result Arrays in Codeigniter.com