Populate the Drop Down List from Database in CodeIgniter Form Return $designation_result = array_combine($designation_id, $designation_name) get designation table to populate the designation dropdownĪrray_push($designation_name, $result->designation_name) Return $department_result = array_combine($dept_id, $dept_name) array to store department id & department nameĪrray_push($dept_name, $result->department_name)
One is to fetch all the records from department table and other one to fetch all the records from the designation table.
#Bootstrap growl notification in codeigniter how to#
Recommended Read: How to Connect to Multiple Databases in CodeIgniter The Model ('models/employee_model.php')įirst create the model file 'employee_model.php' with two functions. `employee_id` int(4) NOT NULL AUTO_INCREMENT, INSERT INTO `tbl_designation` (`designation_id`, `designation_name`) VALUESĬREATE TABLE IF NOT EXISTS `tbl_employee` ( `designation_id` int(4) NOT NULL AUTO_INCREMENT, INSERT INTO `tbl_department` (`department_id`, `department_name`) VALUESĬREATE TABLE IF NOT EXISTS `tbl_designation` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 `department_id` int(4) NOT NULL AUTO_INCREMENT, Now run this sql query in mysql to create the above database.ĬREATE TABLE IF NOT EXISTS `tbl_department` ( The fields that are highlighted in yellow color are primary keys and those ones in green are foreign keys.