| Programming in Joomla Way |
Retrieve HTTP variablesJoomla provided a mosGetParam function to easily retrieve the value of a parameter passed from a previous page:
mosGetParam($_REQUEST, 'id', 0));
if magic_quotes_gpc is off then mosGetParam will automatically escape single quotes, double quotes, backslashes and nulls by adding a backslash character (unless the _MOS_ALLOWRAW option is used). Note that if intend to store the data returned by a mosGetParam call in a database field then will need to perform additional database-specific escaping: datagase->getEscaped. Retrieve data from database
global $database;
$sql = "SELECT * FROM #__categories";
$database->setQuery($sql);
$rows = $database->loadObjectList();
foreach ($rows as $row) {
echo "$row->title; $row->description\n";
}
|