Jeg vil foreslaa denne query:
$queryt = mysql_query("SELECT bt.id, bt.name, p.posttime FROM board_topic bt INNER JOIN posts p ON bt.id = p.board_topicID WHERE bt.board_forumID = $forum[id] ORDER BY p.posttime");
Kommentar: Jeg antager at $forum[id] er en talvaerdi som brugeren vaelger i en form. Fordi jeg ikke ved hvad board_topic.readlevel er skippede jeg det (det fremgaar ikke af dine tabeller.)
For test lavede jeg tre tabeller xsix_board_forum, xsix_board_topic, og xsis_posts med de felter du angav og puttede nogle vaerdier i som jeg gengiver nedenfor. Jeg lavede saa en hjemmeside (hvor jeg i mangel af en bruger-defineret $forum[id] laver min egen og putter den i $id.) Du kan se hjemmesiden her:
http://christianjorgensen.be/xsix.php. Den giver den foelgende udskrift:
forum id: 1 topic name: topic1 posttime: 2010-01-12 12:13:14
forum id: 5 topic name: topic5 posttime: 2010-01-14 12:10:14
forum id: 5 topic name: topic5 posttime: 2010-01-15 12:12:14
forum id: 5 topic name: topic5 posttime: 2010-01-17 12:12:16
Her kommer saa koden til hjemmesiden og indholdet i de tre tabeller:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd"><html>
<head>
<title></title>
</head>
<body>
<?
$link = mysql_connect ('christianjorgensen.be.mysql', 'christianjoygen', 'dnyBKKbe') or die(mysql_erorr());
mysql_select_db('christianjoygen') or die('Could not select database');
$id = $forum[id];
$id = 2;
$queryt = mysql_query("SELECT bt.id, bt.name, p.posttime FROM xsix_board_topic bt INNER JOIN xsix_posts p ON bt.id = p.board_topicID WHERE bt.board_forumID = $id ORDER BY p.posttime");
while($row = mysql_fetch_array($queryt))
echo "forum id: " . $row[id] . " topic name: " . $row[name] . " posttime: " . $row[posttime] . "<br/>";
mysql_close($link);
?>
</body>
</html>
CREATE TABLE xsix_board_forum(id INT, name VARCHAR(10));
CREATE TABLE xsix_board_topic(id INT, name VARCHAR(10), board_forumID INT);
CREATE TABLE xsix_posts(id INT, board_topicID INT, posttime DATETIME);
INSERT INTO xsix_board_forum VALUES(1, 'forum1');
INSERT INTO xsix_board_forum VALUES(2, 'forum2');
INSERT INTO xsix_board_forum VALUES(3, 'forum3');
INSERT INTO xsix_board_topic VALUES(1, 'topic1', 2);
INSERT INTO xsix_board_topic VALUES(2, 'topic2', 3);
INSERT INTO xsix_board_topic VALUES(3, 'topic3', 3);
INSERT INTO xsix_board_topic VALUES(4, 'topic4', 1);
INSERT INTO xsix_board_topic VALUES(5, 'topic5', 2);
INSERT INTO xsix_board_topic VALUES(6, 'topic6', 1);
INSERT INTO xsix_posts VALUES(1, 1, '2010-01-12 12:13:14');
INSERT INTO xsix_posts VALUES(2, 2, '2010-01-12 12:13:24');
INSERT INTO xsix_posts VALUES(3, 3, '2010-01-13 12:13:34');
INSERT INTO xsix_posts VALUES(4, 2, '2010-01-13 12:13:44');
INSERT INTO xsix_posts VALUES(5, 5, '2010-01-14 12:10:14');
INSERT INTO xsix_posts VALUES(6, 2, '2010-01-14 12:11:14');
INSERT INTO xsix_posts VALUES(7, 5, '2010-01-15 12:12:14');
INSERT INTO xsix_posts VALUES(8, 2, '2010-01-16 12:12:15');
INSERT INTO xsix_posts VALUES(9, 5, '2010-01-17 12:12:16');