Here is a snippet of code I often need to build a database query in Joomla.

 


<?php

<?php

$db = JFactory::getDbo();
 
$query = $db->getQuery(true);

// Individual fields 
//$query->select($db->quoteName(array('firstname', 'lastname')));
 // or all fields
$query->select('*') ;

$query->from($db->quoteName('#__free_month')); 
$db->setQuery($query);   $results = $db->loadObjectList();

 echo '<ul>';

foreach ($results as $row) {

echo "<li>{$row->firstname} {$row->lastname}</li>";

}

echo '</ul>';


?>