Dynamic Dropdown from database quesry

Hi to all,
i’m coding some dropdowns that retrieve lists from database and it works enough well.

Something like that:


and function:

function getDirection(){
$database = new medoo([
// required
‘database_type’ => ‘mysql’,
‘database_name’ => ‘database’,
‘server’ => ‘address’,
‘username’ => ‘usert’,
‘password’ => ‘password’,
‘charset’ => ‘utf8’,

$list = array(NULL => "Please Select");
$datas = $database->select("table_name", "*");

foreach($datas as &$data)
    $list[$data['code']] = $data['description'];

return $list;

The dropdown are populated with “description” field( in editview and detailview) like i wanted and the data are saved into database with “code” while in the listview are shown “code” instead of “description” like 2 previous layouts…strange…why?

Then i would like to make 2 type of this dropdowns dependent each other.

like post :


it works with traditional list but not with lists retrieved from database.

Anyone can help me on this two behaviors?

Thank you

Anyone can answer?

Thank you