Hello, I am facing an issue with creating Select with a column name that contains a – character
$sqldpt=”select distinct ‘$site’ as k, ‘$site’ as v from si_dptlist”;
# on change, update other dropdown
$str = $g->get_dropdown_values($sqldpt);
$col[“editoptions”] = array(“value”=>$str);
// load from query on every edit mode
$col[“editoptions”][“onload”][“sql”] = $sqldpt;
the tables contains 3 columns
Voreppe, Brzeg-Dolny,Wesseling
Only issue with column Brzeg-Dolny
If i use this:
$sqldpt=”select distinct ‘$site’ as k, ‘$site’ as v from si_dptlist”;
it works but the select is filled only with Brzeg-Dolny
If I use:
$sqldpt=”select distinct $site as k, $site as v from si_dptlist”;
I get this error:
Couldn’t execute query. Unknown column ‘Brzeg’ in ‘field list’ – select distinct Brzeg-Dolny as k, Brzeg-Dolny as v from si_dptlist
I need some help to get around this issue..
Thanks,
Cedric
Hello,
If you are using mysql, then you should use ` sign around column names.
$sqldpt=”select distinct `$site` as k, `$site` as v from si_dptlist”;