我有一个具有此功能的Customer控制器:
function index(){
$query = $this->db->query("
SELECT ELECTRICITY_BILL_ID,TOTAL_AMOUNT
FROM _ELECTRICITY_BILL where CUSTOMER_LOCATION_ID = 16
");
foreach ($query->result() as $row){
$utility_array = array(
'electricity_bill_id' => $row->ELECTRICITY_BILL_ID,
'amount' => $row->TOTAL_AMOUNT);
}
$this->load->view('Customer',$utility_array);
}
我有一个客户视图:
<?php
foreach($utility_array as $row) {
echo $row['electricity_bill_id'];
echo $row['amount'];
echo "</br >";
}
?>
我的观点中有两个错误:
Undefined variable: utility_array
Invalid argument supplied for foreach()
答案 0 :(得分:0)
用这个改变控制器。
<?php
foreach($data as $row) {
echo $row['electricity_bill_id'];
echo $row['amount'];
echo "</br >";
}
?>
在客户视图中,
viewController
这应该有效。试试这个。
答案 1 :(得分:0)
尝试使用此控制器代码: -
<pre>
Report.Load(reportLocation & filename)
check it using string variable like this;
string getpath = reportLocation & filename;
just check it if its location is the same by checking getpath variable
secondly: crystal report need to login to your working database thats why it says load report failed.
if this one working well then you dont have any problem regarding the crystal report path:
tbs = Report.Database.Tables
For Each tb In Report.Database.Tables
tb.ApplyLogOnInfo(li)
Next
</pre>
如果要将数组或对象传递给视图,则意味着必须为变量分配键。使用该键可以获取视图中的值。 因此,对于 $ utility_array ,您应该分配键值。
答案 2 :(得分:0)
试试这个
在控制器中
function index(){
$query = $this->db->query("SELECT ELECTRICITY_BILL_ID,TOTAL_AMOUNT
FROM _ELECTRICITY_BILL wincache_refresh_if_changed()
WHERE CUSTOMER_LOCATION_ID = 16");
$result = $query->result_array();
if (empty($result)) {
$data['utility_array'] = false;
} else {
$data['utility_array'] = $result;
}
$this->load->view('Customer',$data);
}
在视图中
foreach ($utility_array as $value) {
echo $value['ELECTRICITY_BILL_ID'];
echo $value['TOTAL_AMOUNT'];
echo "<br>";
}