Forums

Load data in the select TAG from table: SOLVED

lapo78 04 Dec, 2011
Hello everyone,,
I have a table with the City field. I want to load the city in a select tag. Can I use Record DB Loader or do I have to write custom code.
Thanks
lapo78 09 Dec, 2011
SOLVED:


<select size="1" label_over="0" hide_label="0" id="nomecomune" class="" title="" type="select" name="nomecomune">
<option value="selected">Selected</option>
<!-- This Scripts used to load data from the DB comuni -->
<?php
$database =& JFactory::getDBO();
$database->setQuery("SELECT nomecomune FROM comuni ORDER BY nomecomune ASC ");

$makes = $database->loadObjectList();
foreach($makes as $make){
echo "<option value=\"".$make->nomecomune."\">" . $make->nomecomune . "</option>\n"; 
}
?>
</select>
This topic is locked and no more replies can be posted.