MyBB Community Forums

Full Version: Very simple Latest Threads block problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This seems like something very simple, but I'm not too familiar with the wording in the coding to get everything working. Hopefully one of you pros can help. Smile

Currently, the Latest Threads block on my home page lists the most recently created threads in order by when they were created. What I would like to do (which seems like the default everywhere else), is change this into a list of threads most recently replied-to.

The problem is, I'm not sure what terms to "call" to get this information for ordering everything. Here's what I have currently:

$threadlimit = 10;
$query = $db->query("
	SELECT t.*, t.subject AS threadsubject, u.username, u.usergroup, u.displaygroup, i.*, i.name AS iconname,
	t.dateline AS threaddate, t.lastpost AS threadlastpost
	FROM ".TABLE_PREFIX."threads t
	LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid=t.icon)
	LEFT JOIN ".TABLE_PREFIX."users u ON (t.lastposter=u.username)
	WHERE t.visible = '1'
	$unviewwhere
	GROUP BY t.tid
	ORDER BY threaddate DESC
	LIMIT 0, $threadlimit
");

Any help would be greatly appreciated! Smile
Ah, it was t.lastpost, of course. Blush
Try changing

ORDER BY threaddate DESC

into

ORDER BY threadlastpost DESC
Try this;
$threadlimit = 10;
$query = $db->query("
    SELECT t.*, t.subject AS threadsubject, u.username, u.usergroup, u.displaygroup, i.*, i.name AS iconname,
    t.dateline AS threaddate, t.lastpost AS threadlastpost
    FROM ".TABLE_PREFIX."threads t
    LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid=t.icon)
    LEFT JOIN ".TABLE_PREFIX."users u ON (t.lastposter=u.username)
    WHERE t.visible = '1'
    $unviewwhere
    GROUP BY t.tid
    ORDER BY t.lastpost DESC
    LIMIT 0, $threadlimit
");