Database lookup
The Database lookup is a MySQL query field which allows you to show the results in a drop-down list or radio button style within your form. Include information from any of the Joomla database fields, including from other components!
Parameters
Field name: Unique name for the field (standard characters only!)
Title: The caption of the field in the form
Description: The information behind the Info button to explain what needs to be filled out.
Show in front-end: Indicator whether this field will be shown in front-end forms
Display as: Rendering mode of the field: Dropdown list or Radio button list
Show empty choice text: Indicator whether to usea empty default option for the list of choices
Empty choice text:Text that will be shown for the default option
SQL query: Query to populate thelist of values (see example for more information)
Example of use
You can use the Database Lookup field to store a database value in a F2C field. The user will be presented a list of values (dropdown or radio buttons) from which he or she can pick al value. The list is populated through a database query.
Let's say we want a user to pick his favourite colour. For this example we use a table called jos_color. You can use any table you want with the Database Lookup, as long as the table is present in the same database as your Joomla installation.
The table might look like this:
| id | color |
| 1 | Red |
| 2 | Green |
| 3 | Blue |
| 4 | Yellow |
| 5 | Purple |
We now must create a database query to populate the list. The query must exactly return two fields per record. The first field will be used as a unique value to identify the record, the second field will be used as the description as shown to the user in the list.
In this example we use the following query:
SELECT id, color FROM jos_color ORDER BY color ASC
