在codeigniter中具有单个表值的下拉列表

时间:2017-06-23 06:41:58

标签: php mysql codeigniter

我的桌子“任务”有; projectname列,员工列和任务列。我想创建3个drodown列表。第一个下拉列表是选择projectname,当选择projectname时,下一个下拉列表将显示谁是员工,其他下拉列表将显示哪些任务。任何人都可以帮我解决这个问题吗? 控制器

public function Income(){

    $data['projectname'] = $this->welcome4->show_students(); 
    $data['tasks'] = $this->welcome4->show_students2(); 

    $this->load->view('template/navigation');
    $this->load->view('template/sideNav');
    $this->load->view('template/header');
    $this->load->view('Income',$data);
    $this->load->view('template/footer');

    } 

模型

function show_students(){
        $query = $this->db->get('task');
        $query_result = $query->result();
        return $query_result;
    } 
    function show_students2(){
        $query = $this->db->get('task');
        $query_result = $query->result();
        return $query_result;
    }

查看

<div class="form-group">
                             <label>Select Project</label>
                        </div>     


                    <div class="form-group">
                        <select name="projectname" class="input form-control">
                        <option value="none" selected="selected">Select Project</option>


                        <?php foreach($projects as $s):?> 
                        <option value="<?php echo $s->projectname?>"><?php echo $s->projectname?></option>
                        <?php endforeach;?>  
                        </select>
                    </div>



                    <div class="form-group">
                             <label>Select task</label>
                        </div> 

                    <div class="form-group">
                        <select name="task" class="input form-control">
                        <option value="none" selected="selected">Select Task</option>


                        <?php foreach($task as $s):?> 
                        <option value="<?php echo $s->task?>"><?php echo $s->employee?></option>
                        <?php endforeach;?>  
                        </select>
                    </div>

0 个答案:

没有答案