What do you mean? My english is not best sorry.
$MyDb = ConnectDatabaseNow();
$a = array("SELECT * FROM %s AS a LEFT JOIN %s AS b OB a.Id=b.AnswerToId WHERE a.ThreadId AND a.State=0 AND a.Deletion='0000-00-00 00:00:00' AND a.AnswerToId='' ORDER BY b.Savedate DESC", 'table');
$s = sprintf($a[0], $a[1], $a[1]); $q = mysqli_query($MyDb, $s);
if (mysqli_num_rows($q) > 0) {
while ($data = mysqli_fetch_array($q)) {
// output of threads ordered by Savedate
}
}
I try to create a forum.
Its load all categories, subcategories, count threads, answer e.g. but i am not able to order them by newest post date.
All posts are in same table (thats why table called twice as a and as b) so i select first all "topics" (by selecting all without a.AnswerToId value) so i try to fetch topics and order them by newest date from posts, if a answer / post is avaidable, else it should take date from first post (topic).
The error actual is that there is no output by these code. If i use this code without LEFT JOIN i will get all topics ordered by topic-date, but i want, if answer avaidable, that it that newest post date for sorting.
If you answer to topic the topic should beeing first result (because it has newest dated post) and if new thread is newer, the newer topic/thread should be shown.