Question about Select and Title.
Question about Select and Title.
Hello,
I have following code to load data from table to select list:
if ( ! isset($_POST['action']) ) {
$out['lecturers'] = $db
->selectDistinct( 'lecturers', 'id_lecturer as value, surname as label' )
->fetchAll();
}
Question is:
It's possible to have few columns names at one label?
For example:
id_lecturer as value, surname & name & middlename as label.
For usability only.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
Yes indeed. The label string can be anything you want and concatenating the values from columns is certainly an option. To do that use the
sql()
method with theconcat
orconcat_ws
SQL functions. For example you might have:Allan
Thank you very much , Allan.
I'd like to add a little for users, who might read this thread.
It is necessary to add "FROM" parameter, because without it there will be no query.
Oops! Thanks for pointing that out!
Allan