Jump to content

help with subforum feature


doddsey_65

Recommended Posts

Okay so I have 2 forums, which each have 1 topic and atleast 1 post within those topics

lets call them forum 1 and forum 2 where the number is the id in the database under forum_id

 

they are in a parent with a parent id of 1 so the database layout is

 

forum_id - forum_parent_id
     1                     1
     2                     1

 

but i want to add a child board/subforum to forum_id 1. So i added two more columns

forum_type

f for forum or c for child board

 

forum_connection

the forum id this child is in(if its a child)

 

but how would i get forum child with a forum_connection of 1 to appear under the forum with an id of one?

 

here is my query:

 

$query = $db->query("SELECT
              f.forum_id, f.forum_name, f.forum_description, 
		  f.forum_topics, f.forum_posts, f.forum_type, forum_connection, 
              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.thread_topic_id, t.topic_name
		  
		FROM forum_parents as p

		JOIN forum_forums as f
			ON f.parent_id = p.parent_id

		LEFT JOIN forum_members as m
			ON f.forum_last_poster = m.user_username

		LEFT JOIN forum_topics as t
			ON t.topic_name = f.forum_last_post
		WHERE f.forum_type = 'f'
		ORDER BY p.parent_id, f.forum_id ASC")
		or trigger_error("SQL", E_USER_ERROR);

 

hopefully someone will understand this lol

Link to comment
https://forums.phpfreaks.com/topic/217601-help-with-subforum-feature/
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.