HOW TO dynamically build dropdown list for filtering fields?

Talk and info about common issues

Moderators: ne_moj, zewa, vadimako, ne_moj, zewa, vadimako

administrator
Site Admin
Site Admin
Posts: 5988
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO dynamically build dropdown list for filtering fields?

Postby administrator » Sep 15th, '12, 17:16

(special thanks to Larry Rathjen)
Here the example for MSSQL, but it can be easy changed to any type of database you work with:

NOTE: DO NOT USE VARCHAR(MAX) or NVARCHAR data types as PHP does not like them.
Under section 7 Add/Edit/Details Mode Settings:

Code: Select all

#Create your query
$query = "SELECT distinct location FROM computer_location_types";
$result = odbc_exec($dbconn,$query);
$location_array = array();;
while($row = odbc_fetch_array($result)){
    $location_array[$row['location']] = "{$row['location']}" ;
}

'location' =>array("header"=>"Location", "type"=>"enum", 'req_type'=>'rt', "align"=>"left", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"simple", "case"=>"normal", "summarize"=>"false", "sort_type"=>"string", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$location_array),   

Return to “ApPHP DataGrid {HOW TO}”