我有一个数组$dtl
:
Array
(
[MODULE_NAME] => Array
(
[0] => Daily_Recurring_Grabber
[1] => Daily_Recurring_Grabber
)
[START_EXECUTION] => Array
(
[0] => 19-SEP-14
[1] => 21-SEP-14
)
[FINISHED_EXECUTION] => Array
(
[0] => 19-SEP-14
[1] => 21-SEP-14
)
[NUM_OF_POPULATION] => Array
(
[0] => 6630
[1] => 6169
)
[SUM_AMOUNT] => Array
(
[0] => 397922098.33
[1] => 360955418.47
)
)
我只想显示SUM_AMOUNT的值。所以我像这样创建视图:
if(isset($dtl)){
foreach($dtl as $row){
?>
<tr>
<td><?php echo $row['sum_amount']; ?></td>
</tr>
但我收到了一个错误:
Severity: Notice
Message: Undefined index: SUM_AMOUNT
Filename: pages/v_soaotc_monthly.php
这是我的模型
$this->pblmig_db = $this->load->database('collprod', true);
$sql="select * from inh_soa_otc_control
where module_name like 'Monthly_Accumulator%'
and finished_execution is not null";
$stmt = oci_parse($this->pblmig_db->conn_id, $sql);
oci_execute($stmt);
$row = oci_fetch_all($stmt, $result);
oci_free_statement($stmt);
oci_close($this->pblmig_db->conn_id);
return $result;
我在代码中遗漏了什么?谢谢你的帮助
答案 0 :(得分:1)
试试这个
<?php
if(count($dtl)>0){
foreach($dtl['SUM_AMOUNT'] as $row){
?>
<tr>
<td><?= $row ?></td>
</tr>
<?php
}
}
?>
对于所有元素
<?php
if(count($dtl)>0){
foreach($dtl as $index => $dt1_element){
//[MODULE_NAME] => Array
?>
<ul>
<li>Data in <?= $index ?></li>
<ul>
<?php
foreach($dt1_element as $row){
//[0] => Daily_Recurring_Grabber
//[1] => Daily_Recurring_Grabber
?>
<!-- Daily_Recurring_Grabber -->
<li><?= $row ?></li>
<?php
}
?>
</ul>
<?php
}
?>
</ul>
<?php
}
?>
答案 1 :(得分:0)
$dtl
已经是一个数组
您可以SUM_AMOUNT
$dtl['SUM_AMOUNT']
通过
获取所有值foreach($dtl as $key => $value){
<tr>
<td><?php echo $value; ?></td>
</tr>
}