//count the number of topics posted in each forum
                    $kunena_db->setQuery("SELECT id FROM #__fb_messages WHERE catid='{$singlerow->id}' AND parent='0' AND hold='0'");
                    $num = $kunena_db->loadObjectList();
                    	check_dberror("Unable to load messages.");
                    $numtopics = count($num);
                    //count the number of replies posted in each forum
                    $kunena_db->setQuery("SELECT id FROM #__fb_messages WHERE catid='{$singlerow->id}' AND parent!='0' AND hold='0'");
                    $num = $kunena_db->loadObjectList();
                    	check_dberror("Unable to load messages.");
                    $numreplies = count($num);
                    //Get the last post from each forum
                    $kunena_db->setQuery("SELECT MAX(time) FROM #__fb_messages WHERE catid='{$singlerow->id}' AND hold='0' AND moved!='1'");
                    $lastPosttime = $kunena_db->loadResult();
                    	check_dberror("Unable to get max time.");
                    //changed lastPosttime to lastptime
                    $lastptime = KUNENA_timeformat(CKunenaTools::fbGetShowTime($lastPosttime));
                    $lastPosttime = (int)$lastPosttime;