· To add any function you should add it to the controller of the component

class UserController extends JController

{

function display()

{

> parent::display();

}

}

· to call function in default.php

defined(‘_JEXEC’) or die(‘Restricted access’);

define(‘JPATH_BASE’, dirname(__FILE__) );

require_once (JPATH_COMPONENT.DS.’controller.php’);

UserController::functionName ();

· Make Ajax Call

index.php?option=com_user&format=raw&view=register&task=cities

· to make database connection inside a function

$database = JFactory::getDBO();

$lists = array();

$query = “SELECT * FROM #__country”;

$database->setQuery($query);

$myQuery=$database->query();

$i=0;

while($myRow = mysql_fetch_array($myQuery)){

$country[$i]['Code'] = $myRow['Code'];

$country[$i]['Name'] = $myRow['Name'];

$i++;

}

· To create a list box from the Database array result

$lists['country'] = JHTML::_(’select.genericList’,

$country, ‘country’, ‘class=”inputbox” onChange=”getCity(this.value)” style=”width:200px”‘. ”, ‘Code’,

‘Name’, $row->country);

echo $lists['country'];