phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Joomla - Module: Show Items from database (Part 3)

Tag: joomla, cms   Category: PHP Framework
post: 19 Nov 2007 read: 2,612


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.

  1. Create a folder named "mod_hello" within joomla/modules.
  2. Create a file named "mod_hello.php" within joomla/modules/mod_hello.
  3. 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



Series this article:
Joomla - Module: Register Database (Part 1)
Joomla - Module: Showing Module at Front End (Part 2)
Joomla - Module: Show Items from database (Part 3)
Joomla - Module: Showing Few Text After Link (Part 4)
Joomla - Module: Using Helper (Part 5)
Joomla - Module: Using Template for Layout Flexibility (Part 6)
Joomla - Module: Trying Alternative Layout (Part 7)
Joomla - Component: Showing Number of Comment at Last Post (Part 8)

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting