Using PHP to create "select" dropdowns
One frequent request is to create a select drop-down from a set of records in a database table. The example here lists all the published articles in section 1.
Getting ready
You'll need to know the MySQL query to extract the records you need from the database table. This requires some Joomla! knowledge and some MySQL know-how.
Joomla! keeps its articles in the jos_content
database table and the two-table columns that we want are the article title and the article id. A quick check in the database tells us that the columns are appropriately called title
and id
. We can also see that the section id column is called sectionid
(with no spaces); the column that tells us if the article is published or not is called state
and takes the values 1
for published and 0
for not published.
How to do it . . .
We are going to use some PHP to look up the information about the articles in the database table and then output the results it finds as a series of options for our...