After registering database and show module at frond ent, now we will display its datas. We will retrieve items from database. This is basic tutorial how to display data from database to module.
- Create a folder named "mod_hello" within joomla/modules.
- Create a file named "mod_hello.php" within joomla/modules/mod_hello.
- Enter following code:
<?php
defined('_JEXEC') or die('Restricted access');
$items = $params->get('items', 1);
$db =& JFactory::getDBO();
$query = "SELECT id
FROM #__hello
WHERE published = '1'
ORDER BY id DESC";
$db->setQuery( $query, 0 , $items );
$rows = $db->loadObjectList();
foreach($rows as $row)
{
echo 'ID: <A href="'. JRoute::_('index.php?option=com_hello&id='.$row->id.'&task=view') .'">'.$row->id.'</A> </br>';
}
?>
You should get