I'm new at PHP and MySQL, trying to make a forum (almost done now 🙂) Here is the problem:
How to sort topics that they are at the begining of forum (if someone had recently posted a reply)... Now I'm sorting topics using topics.topic_time (where the topic was created)...
In other words how to sort results using posts.post_time in topics
Here is how my database is designed:
forumtopics
topic_id int(10) NOT NULL auto_increment,
topic_title varchar(100),
topic_poster int(10),
topic_time varchar(20),
PRIMARY KEY (topic_id)
posts
post_id int(10) NOT NULL auto_increment,
topic_id int(10) DEFAULT '0' NOT NULL,
poster_id int(10),
post_text text,
post_time varchar(20),
PRIMARY KEY (post_id)
My MySQL query looks like this:
$result = mysql_query("SELECT t.*, u.uname FROM forumtopics t, users u WHERE t.topic_poster = u.user_id ORDER BY topic_time DESC LIMIT $limitvalue1, $limit");
and it works ok but when somebody posts new reply to older topic it will not be noticed by anybody because it is at the bottom of the forum....
PLEASE HELP ME