02-12-2008, 08:05 PM
|
#1 (permalink)
|
|
The Contributor
Join Date: Nov 2007
Location: Nashville
Posts: 41
Thanks: 7
|
Selecting Latest Forum Post Threads
I've made a simple user forum on a site. More along the lines of "threaded comments".
On my front page I'd like to show the top 5 latest commented threads.
IE - 5 Threads that received the latest comments.
Code:
CREATE TABLE `forumPost` (
`id` int(5) NOT NULL auto_increment,
`thread` int(5) NOT NULL default '0',
`text` text NOT NULL,
`user` int(5) NOT NULL default '0',
`date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
Code:
CREATE TABLE `forumThread` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
I'm having trouble with the query logic.
Basically something like:
Code:
SELECT * FROM forumPost GROUP BY(DISTINCT(thread)) ORDER BY date DESC
obviously this doesn't work. Any ideas on how to do this without going the easy PHP route?
Thanks
jw
|
|
|