我正在尝试使用 CodeIgniter 从数据库中检索数据。该查询工作正常,并将数据检索到一个数组中,该数组可以用print_array()
.
Array
(
[0] => Array
(
[trans_id] => 33
[CustomerAccountNumber] => BR002
[TransactionType] => Invoice
[TransactionDate] => 2012-09-06 00:00:00
[InvoiceNo] => 00001732262
[OrderNo] => 0000183946
[GoodsValueInAccountCurrency] => 1055.26
[AccountBalance] => 1104.52
[SYSTraderTranTypeID] => 4
)
[1] => Array
(
[trans_id] => 34
[CustomerAccountNumber] => BR002
[TransactionType] => Invoice
[TransactionDate] => 2012-09-19 00:00:00
[InvoiceNo] => 00001375022
[OrderNo] => 0000184907
[GoodsValueInAccountCurrency] => 49.26
[AccountBalance] => 1104.52
[SYSTraderTranTypeID] => 4
)
)
但是,每当我尝试在表格中显示数据以生成 pdf 时,它都会给我一个错误,指出“尝试获取非对象的属性”。但是所有的对象都进入一个数组来显示。这是我的代码:
print_array($data['data']);
{ foreach ($data['data'] as $key=>$link)
{
{
$html .= '
<tr>
<td width = "100">'.$link->InvoiceNo.'</td>
<td width = "300">'.($link->OrderNo).'</td>
<td width = "100">'.($link->TransactionDate).'</td>
<td width = "100">'.($link->TransactionType).'</td>
<td width = "100">'.($link->GoodsValueInAccountCurrency).'</td>
</tr>';
}
}}
但这给了我错误“试图获取非对象的属性”。我没有任何线索。为什么?请帮忙。