Hi,
Given your schema you should delete the ‘topic_date’ row and may be also ‘topic_com’, which I suppose hold the number of comments on a given topic (that info is already on the tables, just COUNT(*) it) and ‘topic_by’.
I think there’s at least a post row for each topic row (the topic’s subject on the topic table and the topic’s content on the post table) so just JOINing should work, since there is no topic without a post (LEFT JOIN) neither a post without a topic it belongs to (RIGHT JOIN).
I sincerely don’t know why it behaves this way.
Left join is used to find rows that don’t match. According to the image in your link, the data in topics.topic_id
and posts.post_topic columns are exactly same, thus matching one by one. That’s why you could not get any
result. As Passionless pointed out, you can get the result by just joining two tables as follows:
$sql = “SELECT
topics.topic_id,
topics.topic_subject,
topics.topic_date,
topics.topic_by,
from topics, posts,
posts.post_topic,
posts.post_content,
posts.post_img
where posts.post_topic=topics.topic_id //This might not be needed if the data in two columns are exactly same.
order by topics.topic_id DESC”;
you guys are amazing!!! THANKS.
BTW I’m really happy the way my page is coming up. You can see it (almost done) but there is still stuff to be done so i’m gonna be bothering for a while more