Tuesday, October 27, 2015

Create Dropdown List with Database values in PHP


Table Stracture
+---------+-----------------+-
| state_id | state_name     |
+---------+-----------------+-
| 1 	   | AP             |
| 2 	   | MH             |
| 3 	   | TS             |
+---------+-----------------+-

$this->SelCon->select('state_id,state_name')->from('states')-> order_by ('state_name', 'ASC');
$qry = $this->SelCon->get();
return $qry->result_array();


Array
(
    [0] => Array
        (
            [state_id] => 1
            [state_name] => AP
        )

    [1] => Array
        (
            [state_id] => 2
            [state_name] => MH
        )

    [2] => Array
        (
            [state_id] => 3
            [state_name] => TS
        )