我没有关于这个问题的MVC数据,但您可以通过其他示例帮助我
答案 0 :(得分:0)
这是你的控制器Demo.php:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Demo extends CI_Controller {
public function __construct(){
parent::__construct();
}
$this->load->model('demo_model');
$this->load->helper('url');
function display_content()
{
$data = array();
$data['result'] = $this->demo_model->get_records();
$this->load->view('demo/show_content', $data);
}
}
您的模型为demo_model.php:
class demo_model extends CI_Model
{
function get_records()
{
$this->db->select('your tbl columns'); //Ex: u_id,fname,lname
$this->db->from('your tbl name'); // tbl_user
$this->db->order_by("title", "desc"); //u_id
$query = $this->db->get();
return $result = $query->result();
}
}
您的视图文件为show_content.php:
<table>
<tr>
<th>All Records</th>
</tr>
<?php foreach($result as $res): ?>
<tr><?php echo $res->content; ?></tr>
<?php endforeach; ?>
</table>
?>
这是示例,现在您必须根据需要设置所有参数......