I have a module which has dropdown select boxes. I have a table in the database, which is associated to a component, which the module is associated with.
If the component database table has data in it, how can I get the module to display the data in a dropdown and if selected it will show the results on a separate page?
For example, I have the following dropdowns in the module:
<label for="airport">Airport:</label> <select id="airport" name="airport"> <option selected="selected" value="A">Any Airport</option> <option value="LGW">Gatwick</option> <option value="MAN">Manchester</option> </select>
In the database, there is a table called "dep", it has either MAN or LGW in it. If the user selects LGW from the dropdown and then clicks search, I want the component to load all of the data from the database which has got LGW in the table.
I have set the following Database query in the module, but how can I use this to show the data in the dropdowns and then show the correct results?
$db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select($db->quoteName(array('mykey', 'hotelName', 'resortName', 'dep', 'startDate', 'sellingPrice'))); $query->from($db->quoteName('#__availability')); $query->order('ordering ASC'); $db->setQuery($query); $results = $db->loadObjectList();