i want to retrieve data from database in my module page.for that my helloworld.php put the code
// Get a database object
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id, description');
$query->from('#__banners');
// sets up a database query for later execution
$db->setQuery($query);
// fetch result as an object list
$result = $db->loadObjectList();
now i want to show the results in default.php. but when echo $result in default.php it dose not show anything. how to i show the result? how to i get data from #__banners table?
$db->loadObjectList()
returns an array which you can't echo. You can create a foreach
loop like so:
foreach ( $result as $row ) {
echo $row->description;
}