display data from database to dropdown CodeIgniter

后端 未结 6 1446
星月不相逢
星月不相逢 2020-12-03 08:54

I\'m having difficulty with display data from the db to dropdown.

This is what I have tried:

Model.php

        public funct         


        
6条回答
  •  自闭症患者
    2020-12-03 09:41

    This is what you should do:

    Model:

    public function __construct()
    {
        parent::__construct();
    }
    
    function getAllGroups()
    {
        $query = $this->db->query('SELECT description FROM location');
        return $this->db->query($query)->result();
    }
    

    Controller:

    load->model('delivery_model');
        }
        public function index()
        {
            $data['title']= 'Warehouse - Delivery';
            $data['groups'] = $this->delivery_model->getAllGroups();
            //I take here a sample view, you can put more view pages here
            $this->load->view('include/header',$data);
        }
    }
    

    View:

    
    

提交回复
热议问题