ci框架 省市三级联动
只要在ci中引入这个就可以了简单
load->view('district_select',$data);
?>1. [文件] district_select.php
load->model('region_model', 'region');
$provinces = $CI->region->provinces();
$citys = $CI->region->children_of($province_selected);
?>
2. [文件] region_model.php
db->select($select);
$this->db->where('parent_id', $parent_id);
if ($query = $this->db->get('region')){
return $query->result_array();
}
return array();
}
// --------------------------------------------------------------------
/**
*
*
* @return array
*/
function provinces()
{
return $this->children_of(1);
}
// --------------------------------------------------------------------
/**
* 区域名
*
*
*/
function get_name($id)
{
if (!$id){
return array();
}
$this->db->select('region_name');
$query = $this->db->get_where('region',array('region_id' => $id));
if ($row = $query->row_array()){
return $row['region_name'];
}
return array();
}
// --------------------------------------------------------------------
/**
* load by id
*
*
*/
function load($id)
{
if (!$id){
return array();
}
$query = $this->db->get_where('region',array('region_id' => $id));
if ($row = $query->row_array()){
return $row;
}
return array();
}
} 以上就是ci框架 省市三级联动的内容,更多相关内容请关注PHP中文网(www.php.cn)!










