TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 02-12-2008, 08:05 PM   #1 (permalink)
The Contributor
 
aristoworks's Avatar
 
Join Date: Nov 2007
Location: Nashville
Posts: 41
Thanks: 7
aristoworks is on a distinguished road
Default 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
Send a message via AIM to aristoworks
aristoworks is offline  
Reply With Quote
Old 02-12-2008, 10:05 PM   #2 (permalink)
The Frequenter
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 354
Thanks: 3
xenon is on a distinguished road
Default

Perhaps this is what you want to achieve:

Code:
SELECT DISTINCT(thread) FROM forumPost [...]
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:45 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0