Reputation: 275
I am new in joomla.In my module i have to give select category option. I tried to get category name from back-end by following code but it doesn't work.Code..
$backId=$params->get('mycategory');
$db->setQuery('SELECT cat.title FROM #__categories cat RIGHT JOIN #__content cont ON cat.id = cont.catid WHERE cont.id='.$backId);
$category_title = $db->loadResult();
if ($category_title)
{
echo $category_title;
}
how can i get the category name that i selected.Thanks...
Upvotes: 3
Views: 4199
Reputation: 71
Hope this may be work..
$db = JFactory::getDbo();
$id = jrequest::getint('id');
//match id to cat.id from _categories set to variable $id
$db->setQuery("SELECT cat.title FROM #__categories cat WHERE cat.id='$id'");
$category_title = $db->loadResult();
echo "$id";
echo "$category_title";
Upvotes: 3