codeigniter

时间:2017-02-21 05:01:45

标签: codeigniter

我想在codeigniter中创建多个下拉列表,在我的情况下,当用户选择中心时,下一个列表应该提供该中心的协调员选项。是否可以从数据库中提供加载选项。

查看

<div class="form-group">
    <label class="control-label col-lg-2">Select Center<span class="text-danger">*</span> </label>
    <div class="col-lg-9">
        <select name="center" class="form-control required">
            <option value="">Choose an option</option>
        </select>
    </div>
</div>
<div class="form-group">
    <label class="control-label col-lg-2">Co-ordinator<span class="text-danger">*</span> </label>
    <div class="col-lg-9">
        <select name="co-ordinator" class="form-control required">
            <option value="">Choose an option</option>
        </select>
    </div>
</div>

控制器

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class House extends CI_Controller 
{

    public function __construct()
    { 
        parent::__construct();
        $this->load->helper('url');
        $this->load->model('admin/Hose_model');
        $this->load->library('session');
    }

    public function index()
    {   
        $dis['res']=$this->Hose_model->display()->result_array();
        $this->load->view('admin/house',$dis);
    }
    public function add()
    {            
         $data['center']=$this->input->post('center');
         $data['co-ordinator']=$this->input->post('co-ordinator');
         $this->Hose_model->db_insert($data);
         redirect("admin/house");
         $this->load->view('admin/newhouse');               
    }  
}

型号

public function db_insert($data)
{
    $query=$this->db->insert('hose_db',$data);
    return $query;
}

0 个答案:

没有答案