MyBB Community Forums

Full Version: Fetch lates threads from the category?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How to make this query to fetch threads from the category?


$query = $db->query("
		SELECT t.*, t.subject AS threadsubject, u.username, u.usergroup, u.displaygroup,
		t.dateline AS threaddate, t.lastpost AS threadlastpost
		FROM ".TABLE_PREFIX."threads t
		LEFT JOIN ".TABLE_PREFIX."threadprefixes p ON (p.pid=t.prefix)
		LEFT JOIN ".TABLE_PREFIX."users u ON (t.lastposter=u.username)
                WHERE t.fid = ".intval($mybb->input['fid'])."
		GROUP BY t.tid
		ORDER BY t.lastpost DESC
		LIMIT 0, {$threadlimit}
	");