Monthly Archives: September 2013

google map with calculate between more than two places in php

$travel_location = ‘1st main Road&Peenya Industrial Area’;

$bootloca = explode(‘&’,$travel_location);
$origins = str_replace(‘ ‘, ‘+’, $_REQUEST[‘city’]);
$destinations = ”;
foreach($bootloca as $book):
$destinations = $destinations.str_replace(‘ ‘, ‘+’, $book).’|’;



//print ‘<pre>’;
//print_r($json);   // for check array value
//print ‘</pre>’;
$total_distance = 0;
foreach($json[“rows”][0][“elements”] as $dist):

$total_distance += ceil($dist[“distance”][“text”]);


print $total_distance;


Logout link for Joomla 1.5, 2.5

Joomla 1.5 Logout Link

$returnURL = base64_encode(JURI::root() . “”);
$user =& JFactory::getUser();
echo ‘Hi,’.$user->username;

<a href=”index.php?option=com_user&task=logout&return=<?php echo $returnURL; ?>”>
<input  type=”button” name=”Submit” value=”Logout”></a>

Joomla 2.5 Logout Link

<a href=”index.php?option=com_users&task=user.logout&<?php echo JUtility::getToken(); ?>=1″>
<input  type=”button” name=”Submit” value=”Logout”>


Edit profile link for joomla 2.5

<a href=”<?php echo JRoute::_(‘index.php?option=com_users&view=profile&layout=edit’)?>” title=”My Profile”>Edit Profile</a>


how to access Joomla 2.5!: Classes for Accessing Database for mysql

For select Query:

$db = JFactory::getDBO();
$query = $db->getQuery(true);
$results = $db->loadObjectList();
if ($results){
    foreach($results as $result) 
For insert Query:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->set("field1='value1', fieldn='valuen'");
To get the last insert id, use:

For udate Query:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->set("field1='value1', fieldn='valuen'");
For simple query: 
$db = JFactory::getDbo();
$query = "<YOUR QUERY>";

For fetch multiple row:

Your Query goes here
$items = $db->loadObjectList();

For fetch Single row:

Your Query goes here
$book_item = $db->loadObject();