doufu9145 2019-06-30 07:02 采纳率: 0%
浏览 152

数组循环通过foreach不显示任何数据

I was working with an array which I have to list in a view page. so I iterated the array using a foreach loop. but it's not displaying any data and throwing an error like

trying to get property of non-object

I have tried the normal way but didn't get it

<div class="scrollbar1 table-content">
<?php
foreach($items_list as $row)
{
?>
<div class="table-row">
<div class="row list_row_style color_black common_rows">

<div class="col-md-12 no_padding">
<a href="add_ledger_sub_type?ledger_name=<?php echo $row->ledger_name; ? 
>">
<div class="row">
<div class="col-md-2   list_common_text_style table-data">
<?php echo $i; ?></div>
<div class="col-md-3   list_common_text_style table-data" >
<?php if(!empty($row->sub_ledger_name)) echo $row->sub_ledger_name; ?>
</div>
<div class="col-md-3   list_common_text_style table-data" >
<?php if(!empty($row->ledger_name)) echo $row->ledger_name; ?>
</div>
<div class="col-md-4   list_common_text_style table-data" >
<?php if(!empty($row->description)) echo $row->description; ?>
</div>
</div></a>
</div>
</div>
</div>
<?php
$i++;
}
?>
</div>

My expected result is this code lists all items in '$items_list' array. But it's not

Please help me.

  • 写回答

2条回答 默认 最新

  • dongwen7380 2019-06-30 07:22
    关注

    Yes, I got the answer. It was a small mistake. I took the items to an array in database_models and again stored to another array in 'controller'.

    评论

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊