function showResults() { $database = JFactory::getDBO(); //Retrieve search string $searchtext = rsgInstance::getVar('searchtext', ''); //Check searchtext against database $sql = "SELECT *, a.name as itemname, a.id as item_id FROM #__rsgallery2_files as a, #__rsgallery2_galleries as b " . "WHERE a.gallery_id = b.id " . "AND (" . "a.title LIKE '%{$searchtext}%' OR " . "a.descr LIKE '%{$searchtext}%'" . ") " . "AND a.published = 1 " . "AND b.published = 1 " . "GROUP BY a.id " . "ORDER BY a.id DESC"; $database->setQuery($sql); $result = $database->loadObjectList(); //show results html_rsg2_search::showResults($result, $searchtext); }