Jump to content

query problems


doddsey_65

Recommended Posts

I have a query which pulls all the data i need and it works fine. But when there is more than one topic in a forum it displays the forum each time. Say there are 4 topics in a forum. The forum name is displayed 4 times. Heres the code:

 

$query = $db->query("SELECT
              f.forum_id, f.forum_name, f.forum_description, f.forum_topics, f.forum_posts,
              f.forum_last_poster, f.forum_last_post_time, f.forum_last_post,
              p.parent_id, p.parent_name,
              m.user_id, m.user_username, m.user_group,
              t.topic_id, t.topic_name,
              po.post_id, po.post_subject
          FROM ".DB_PREFIX."forums as f
          JOIN ".DB_PREFIX."parents as p
              ON f.parent_id = p.parent_id
          LEFT JOIN ".DB_PREFIX."members as m
              ON f.forum_last_poster = m.user_id
          LEFT JOIN ".DB_PREFIX."topics as t
              ON f.forum_id = t.forum_id
          LEFT JOIN ".DB_PREFIX."posts as po
              ON po.post_id = f.forum_last_post
          ORDER BY p.parent_id")
          or trigger_error("SQL", E_USER_ERROR);

while ($forum_info = mysql_fetch_object($query))
{

 

I am new to table joins but someone helped me set this up so it should work but it doesnt. Any ideas why?

Link to comment
https://forums.phpfreaks.com/topic/214799-query-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.