我需要在 CodeIgniter 视图文件中回显一个变量值。但是当我运行该网站时...
<?php echo $highcharts; ?>
...在第 108 行,在视图中,它给出了一个错误。请帮助我回显该值,以便我可以在 HighCharts 中使用它。
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: highcharts
Filename: reports/bqt_daily_income_view.php
Line Number: 108
这是我的控制器:
function bqt_daily_income() {
$json_data = array();
$query = $this->db->query("SELECT time_stamp, SUM(paid) AS income FROM payments WHERE type = 'Banquet Reservation' GROUP BY time_stamp ORDER BY time_stamp ASC LIMIT 30");
if ($query->num_rows() > 0) {
foreach($query->result_array() as $row) {
$json_data['data'][] = (int) $row['income'];
}
}
$highcharts = json_encode($json_data);
//return $json_data;
//print_r($json_data); // Array ( [data] => Array ( [0] => 1700 [1] => 5000 ) )
//print_r($highcharts); // {"data":[1700,5000]}
$this->load->view('reports/bqt_daily_income_view', $highcharts);