控制器:
function past_event(){
$this->load->model('usermodel');
$data = $this->usermodel->past();
$this->load->view('past_event',$data);
}
查看:
<p> <h4> Welcome to Past Events </h4> </p>
<?php foreach($res->result_array() as $row){
$ev_name = $row['ev_name'];
$image = $row['ev_image'];
$start = $row['start'];
$end = $row['end'];
$desc = $row['ev_desc'];
$ev_id = $row['ev_id'];
$res = array( 'ev_name' => $ev_name,
'ev_image' => $image,
'start' => $start,
'end' => $end,
'ev_desc' => $desc
);
}
?>
答案 0 :(得分:0)
更改您的控制器
function past_event(){
$this->load->model('usermodel');
$data['res'] = $this->usermodel->past();
$this->load->view('past_event',$data);
}
并使用此代码在您的视图中查看结果
<?php foreach($res as $obj){
echo $obj->ev_name.'--'.$obj->ev_image.'--'.$obj->start.'--'.$obj->end.'--'.$obj->ev_desc.'--'.$obj->ev_id;
echo '<br><br>';
}
?>