请帮助我,我有问题获得数据库的价值 我在一个页面中调用了result(),如下面的代码:
<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>
和下一个代码:
<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>
但是当我运行此页面时不能使用消息: 调用未定义的函数result()
答案 0 :(得分:1)
更改此
<?php foreach ($burung.result() as $burung) {
到这个
<?php foreach ($burung->result_array() as $row) {
和内部代码$row['burung']
使用/更改
result_array()
代替result()
。阅读此Result Arrays in Codeigniter.com