查看代码
<?php foreach($payment as $test){?>
<tr>
<td><?php echo $test->customerName;?></td>
<td><?php echo $test->dateTime;?></td>
<td><?php echo $test->amount;?></td>
</tr>
<?php }?>
控制器代码
function __construct() {
parent::__construct();
$this->load->database();
$this->load->model('Income_sales_model');
}
public function index()
{
$this->data['pja_test'] = $this->Income_sales_model->get_all();
$this->load->view('income_sales_view', $data);
}
**这里是我的错误**
答案 0 :(得分:1)
您尝试访问的变量必须是$data
的密钥...
因此,在您的视图中print_r($pja_test);die;
您将获得适当的输出
如果还有任何问题,请告诉我
答案 1 :(得分:0)
控制器代码
function __construct() {
parent::__construct();
$this->load->database();
$this->load->model('Income_sales_model');
}
public function index()
{
$data['payment'] = $this->Income_sales_model->get_all(); // $query->result();
$this->load->view('income_sales_view', $data);
}