Free Mambo Templates - Free Joomla Templates
Joomla Hut HomeContact UsJoomla LinksMambo Forum - Joomla ForumJoomla Downloads

Search

Login Form

 
Joomla Website

Creating a quick and easy Mambo component

 

hello_world.php - Frontend display

<?php
//hello_world Component//
/**
* Content code
* @package hello_world
* @Copyright (C) 2004 Doyle Lewis
* @ All rights reserved
* @ hello_world is Free Software
* @ Released under GNU/GPL License :
http://www.gnu.org/copyleft/gpl.html
* @version 1.0
**/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

global $database;
$query = "SELECT * FROM jos_hello_world LIMIT 1";
$database->setQuery( $query );
$rows = $database->loadObjectList();
$row = $rows[0];

echo $row->text;

?>

Now let's look at how the file works:

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
This makes sure Mambo is calling the file. Very important for security.

global $database;
Sets $database as a global variable so you can use it within your function.

$query = "SELECT * FROM jos_hello_world LIMIT 1";
Selects the first entry in the jos_hello_world table in the database.

$database->setQuery( $query );
Maps your query to the $database class.

$rows = $database->loadObjectList();
Creates a variable named $rows that stores all of the database information as an array.

$row = $rows[0];
Creates a variable named $row that stores only the first value in the $rows array.

echo $row->text;
Writes the value for text to the screen.

 

You have no rights to post comments

 
 
Joomla Jobs
 
 
Joomla Flash Tutorials
   
     
Home   |   Contact   |   Links   |   Forum   |   Downloads  |  Media Kit
 

© Copyright 2003 - 2006 by BUYHTTP, LLC. All rights reserved.
None of the text or images in this public website may be copied without the expressed written consent of the authors.
Powered By Joomla!