|
$db['default']['hostname'] = ".";
$db['default']['dbdriver'] = "mssql";
<?php
class Cate extends Controller{
function Cate(){
parent::Controller();
$this->load->database();
$this->load->helper('url');
$this->load->helper('text');
$this->load->helper('form');
$this->load->model('mcate');
}
//获取所有分类
function cates(){
$data['cate_name'] = $this->mcate->get_all_cate();
$this->load->view('cate/cate_show',$data);
}
}
?>
<?php
class Mcate extends Model{
function Mcate (){
parent::Model();
}
//获取所有分类
function get_all_cate(){
$sql = "select * from cate";
$res = $this->db->query($sql);
return $res->result_array();
}
}
?>
view
<li class="lis">分类名:</li>
<?php foreach ($cate_name as $res):?>
<li class="lis"><?php echo $res['cate_name'];?></li>
<?php endforeach;?>
看了半天没看出错误,是不是配置问题? |
|