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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.