I have a forum on my site with this structure:
CREATE TABLE px_topics (
topic_id int(20) NOT NULL auto_increment,
parent_id int(20) NOT NULL default '0',
root_id int(20) NOT NULL default '0',
name varchar(255) NOT NULL default '',
description text,
create_dt timestamp(14) NOT NULL,
modify_dt timestamp(14) NOT NULL default '00000000000000',
author varchar(255) NOT NULL default '',
author_host varchar(255) NOT NULL default '',
forumid int(5) NOT NULL default '0',
hits int(5) NOT NULL default '0',
PRIMARY KEY (topic_id)
) TYPE=MyISAM;
An this is the query I use to get only the first thread on mainview.
$query = "SELECT DISTINCT t.topic_id, t.parent_id, t.root_id, t.name, t.description, t.author, t.author_host, DATE_FORMAT(t.create_dt, '%d/%m-%Y kl. %H:%i') as dato, t.modify_dt, t.forumid, t.hits FROM px_topics t , px_topics r WHERE t.topic_id = r.root_id AND t.forumid = '0' ORDER BY t.create_dt DESC";
This table is now ordered by the creation dato for the root_id, is it possiple to sort this based on the last entry in a thread? You know what I mean?