BetaONE will rise again!


Reply
  #1  
Old 16th Dec 03, 11:58 PM
robinwilson16 robinwilson16 is offline
Administrator
 
Join Date: Jul 2001
Location: UK
Posts: 903
robinwilson16 will become famous soon enoughrobinwilson16 will become famous soon enough
I have written this bit of code for the latest posts to display on my portal. I have written a different query for each member group so that different forums are available to each but I have to remeber to change it whenever I add or remove forums. I want it to go from the read_perms value of the ib_beta_forums but all the member groups that can view the forum are contained in the same data cell seperated by commas and I tried using leftjoin to associate the members table, the groups table and the forums table but the query wasn't working

Thanks
Here is the code I have:

Code:
if ( $member['group_id'] == 4 ) { //admin     $ipb_query = mysql_query("SELECT DISTINCT t.tid, t.title, t.last_poster_name, t.last_poster_id, t.starter_id, t.starter_name, t.forum_id, f.read_perms FROM ".$ipb_table_prefix."topics t INNER JOIN ".$ipb_table_prefix."forums f ON t.forum_id = f.id where t.forum_id = 1 or t.forum_id = 2 or t.forum_id = 30 or t.forum_id = 58 or t.forum_id = 45 or t.forum_id = 3 or t.forum_id = 10 or t.forum_id = 33 or t.forum_id = 38 or t.forum_id = 50 or t.forum_id = 55 or t.forum_id = 19 or t.forum_id = 35 or t.forum_id = 42 or t.forum_id = 23 or t.forum_id = 36 or t.forum_id = 13 or t.forum_id = 14 or t.forum_id = 54 or t.forum_id = 46 or t.forum_id = 47 or t.forum_id = 16 or t.forum_id = 51 or t.forum_id = 52 or t.forum_id = 17 or t.forum_id = 53 or t.forum_id = 20 or t.forum_id = 43 or t.forum_id = 44 or t.forum_id = 12 or t.forum_id = 41 or t.forum_id = 56 ORDER BY t.last_post DESC LIMIT ".$ipb_limit, $ipb_db_connection); } else if ( $member['group_id'] == 7 ) { //supermods $ipb_query = mysql_query("SELECT DISTINCT t.tid, t.title, t.last_poster_name, t.last_poster_id, t.starter_id, t.starter_name, t.forum_id, f.read_perms FROM ".$ipb_table_prefix."topics t INNER JOIN ".$ipb_table_prefix."forums f ON t.forum_id = f.id where t.forum_id = 1 or t.forum_id = 2 or t.forum_id = 30 or t.forum_id = 58 or t.forum_id = 45 or t.forum_id = 3 or t.forum_id = 10 or t.forum_id = 33 or t.forum_id = 38 or t.forum_id = 50 or t.forum_id = 55 or t.forum_id = 19 or t.forum_id = 35 or t.forum_id = 42 or t.forum_id = 23 or t.forum_id = 36 or t.forum_id = 13 or t.forum_id = 14 or t.forum_id = 54 or t.forum_id = 46 or t.forum_id = 47 or t.forum_id = 16 or t.forum_id = 51 or t.forum_id = 52 or t.forum_id = 17 or t.forum_id = 53 or t.forum_id = 20 or t.forum_id = 43 or t.forum_id = 44 or t.forum_id = 12 or t.forum_id = 41 or t.forum_id = 56 ORDER BY t.last_post DESC LIMIT ".$ipb_limit, $ipb_db_connection); } else if ( $member['group_id'] == 19 ) { //globalmods $ipb_query = mysql_query("SELECT DISTINCT t.tid, t.title, t.last_poster_name, t.last_poster_id, t.starter_id, t.starter_name, t.forum_id, f.read_perms FROM ".$ipb_table_prefix."topics t INNER JOIN ".$ipb_table_prefix."forums f ON t.forum_id = f.id where t.forum_id = 1 or t.forum_id = 2 or t.forum_id = 30 or t.forum_id = 58 or t.forum_id = 45 or t.forum_id = 3 or t.forum_id = 10 or t.forum_id = 33 or t.forum_id = 38 or t.forum_id = 50 or t.forum_id = 55 or t.forum_id = 19 or t.forum_id = 35 or t.forum_id = 42 or t.forum_id = 23 or t.forum_id = 36 or t.forum_id = 13 or t.forum_id = 14 or t.forum_id = 54 or t.forum_id = 46 or t.forum_id = 47 or t.forum_id = 16 or t.forum_id = 51 or t.forum_id = 52 or t.forum_id = 17 or t.forum_id = 53 or t.forum_id = 20 or t.forum_id = 43 or t.forum_id = 44 or t.forum_id = 12 or t.forum_id = 41 ORDER BY t.last_post DESC LIMIT ".$ipb_limit, $ipb_db_connection); } else if ( $member['group_id'] == 6 ) { //mods $ipb_query = mysql_query("SELECT DISTINCT t.tid, t.title, t.last_poster_name, t.last_poster_id, t.starter_id, t.starter_name, t.forum_id, f.read_perms FROM ".$ipb_table_prefix."topics t INNER JOIN ".$ipb_table_prefix."forums f ON t.forum_id = f.id where t.forum_id = 1 or t.forum_id = 2 or t.forum_id = 30 or t.forum_id = 58 or t.forum_id = 45 or t.forum_id = 3 or t.forum_id = 10 or t.forum_id = 33 or t.forum_id = 38 or t.forum_id = 50 or t.forum_id = 55 or t.forum_id = 19 or t.forum_id = 35 or t.forum_id = 42 or t.forum_id = 23 or t.forum_id = 36 or t.forum_id = 13 or t.forum_id = 14 or t.forum_id = 54 or t.forum_id = 46 or t.forum_id = 47 or t.forum_id = 16 or t.forum_id = 51 or t.forum_id = 52 or t.forum_id = 17 or t.forum_id = 53 or t.forum_id = 20 or t.forum_id = 43 or t.forum_id = 44 or t.forum_id = 12 or t.forum_id = 41 ORDER BY t.last_post DESC LIMIT ".$ipb_limit, $ipb_db_connection); } else if ( $member['group_id'] == 14 ) { //News Posters $ipb_query = mysql_query("SELECT DISTINCT t.tid, t.title, t.last_poster_name, t.last_poster_id, t.starter_id, t.starter_name, t.forum_id, f.read_perms FROM ".$ipb_table_prefix."topics t INNER JOIN ".$ipb_table_prefix."forums f ON t.forum_id = f.id where t.forum_id = 1 or t.forum_id = 2 or t.forum_id = 30 or t.forum_id = 58 or t.forum_id = 45 or t.forum_id = 3 or t.forum_id = 10 or t.forum_id = 33 or t.forum_id = 38 or t.forum_id = 50 or t.forum_id = 55 or t.forum_id = 19 or t.forum_id = 35 or t.forum_id = 42 or t.forum_id = 23 or t.forum_id = 36 or t.forum_id = 13 or t.forum_id = 14 or t.forum_id = 54 or t.forum_id = 46 or t.forum_id = 47 or t.forum_id = 16 or t.forum_id = 51 or t.forum_id = 52 or t.forum_id = 17 or t.forum_id = 53 or t.forum_id = 20 or t.forum_id = 43 or t.forum_id = 44 or t.forum_id = 12 or t.forum_id = 41 ORDER BY t.last_post DESC LIMIT ".$ipb_limit, $ipb_db_connection); } else if ( $member['group_id'] == 18 ) { //fund donors $ipb_query = mysql_query("SELECT DISTINCT t.tid, t.title, t.last_poster_name, t.last_poster_id, t.starter_id, t.starter_name, t.forum_id, f.read_perms FROM ".$ipb_table_prefix."topics t INNER JOIN ".$ipb_table_prefix."forums f ON t.forum_id = f.id where t.forum_id = 1 or t.forum_id = 2 or t.forum_id = 30 or t.forum_id = 58 or t.forum_id = 45 or t.forum_id = 3 or t.forum_id = 10 or t.forum_id = 33 or t.forum_id = 38 or t.forum_id = 50 or t.forum_id = 55 or t.forum_id = 19 or t.forum_id = 35 or t.forum_id = 42 or t.forum_id = 23 or t.forum_id = 36 or t.forum_id = 13 or t.forum_id = 14 or t.forum_id = 54 or t.forum_id = 46 or t.forum_id = 47 or t.forum_id = 16 or t.forum_id = 51 or t.forum_id = 52 or t.forum_id = 17 or t.forum_id = 53 or t.forum_id = 20 or t.forum_id = 43 or t.forum_id = 44 ORDER BY t.last_post DESC LIMIT ".$ipb_limit, $ipb_db_connection); } else if ( $member['group_id'] == 12 ) { //Members.. $ipb_query = mysql_query("SELECT DISTINCT t.tid, t.title, t.last_poster_name, t.last_poster_id, t.starter_id, t.starter_name, t.forum_id, f.read_perms FROM ".$ipb_table_prefix."topics t INNER JOIN ".$ipb_table_prefix."forums f ON t.forum_id = f.id where t.forum_id = 1 or t.forum_id = 2 or t.forum_id = 30 or t.forum_id = 58 or t.forum_id = 45 or t.forum_id = 3 or t.forum_id = 10 or t.forum_id = 33 or t.forum_id = 38 or t.forum_id = 50 or t.forum_id = 55 or t.forum_id = 19 or t.forum_id = 35 or t.forum_id = 42 or t.forum_id = 23 or t.forum_id = 36 or t.forum_id = 13 or t.forum_id = 14 or t.forum_id = 54 or t.forum_id = 46 or t.forum_id = 47 or t.forum_id = 16 or t.forum_id = 51 or t.forum_id = 52 or t.forum_id = 17 or t.forum_id = 53 or t.forum_id = 20 or t.forum_id = 43 ORDER BY t.last_post DESC LIMIT ".$ipb_limit, $ipb_db_connection); } else if ( $member['group_id'] == 10 ) { //Members. $ipb_query = mysql_query("SELECT DISTINCT t.tid, t.title, t.last_poster_name, t.last_poster_id, t.starter_id, t.starter_name, t.forum_id, f.read_perms FROM ".$ipb_table_prefix."topics t INNER JOIN ".$ipb_table_prefix."forums f ON t.forum_id = f.id where t.forum_id = 1 or t.forum_id = 2 or t.forum_id = 30 or t.forum_id = 58 or t.forum_id = 45 or t.forum_id = 3 or t.forum_id = 10 or t.forum_id = 33 or t.forum_id = 38 or t.forum_id = 50 or t.forum_id = 55 or t.forum_id = 19 or t.forum_id = 35 or t.forum_id = 42 or t.forum_id = 23 or t.forum_id = 36 or t.forum_id = 13 or t.forum_id = 14 or t.forum_id = 54 or t.forum_id = 46 or t.forum_id = 47 or t.forum_id = 16 or t.forum_id = 51 or t.forum_id = 52 or t.forum_id = 17 or t.forum_id = 53 ORDER BY t.last_post DESC LIMIT ".$ipb_limit, $ipb_db_connection); } else { //Members $ipb_query = mysql_query("SELECT DISTINCT t.tid, t.title, t.last_poster_name, t.last_poster_id, t.starter_id, t.starter_name, t.forum_id, f.read_perms FROM ".$ipb_table_prefix."topics t INNER JOIN ".$ipb_table_prefix."forums f ON t.forum_id = f.id where t.forum_id = 1 or t.forum_id = 2 or t.forum_id = 30 or t.forum_id = 58 or t.forum_id = 45 or t.forum_id = 3 or t.forum_id = 10 or t.forum_id = 33 or t.forum_id = 38 or t.forum_id = 50 or t.forum_id = 55 or t.forum_id = 19 or t.forum_id = 35 or t.forum_id = 42 or t.forum_id = 23 or t.forum_id = 36 or t.forum_id = 13 or t.forum_id = 14 or t.forum_id = 54 or t.forum_id = 46 or t.forum_id = 47 ORDER BY t.last_post DESC LIMIT ".$ipb_limit, $ipb_db_connection); }
Reply With Quote
  #2  
Old 17th Dec 03, 10:24 AM
robinwilson16 robinwilson16 is offline
Administrator
 
Join Date: Jul 2001
Location: UK
Posts: 903
robinwilson16 will become famous soon enoughrobinwilson16 will become famous soon enough
Think I've found it:

Code:
mysql_query("SELECT `id`, `read_perms` FROM {$ipb_table_prefix}forums"); while($r = mysql_fetch_row()) { $perms = explode(",", $r['read_perms']); if(in_array($member['group_id'], $perms) { $forums[$r['id']] = "t.forum_id = {$r['id']}"; } } $forum_string = implode(" OR ", $forums); mysql_query("SELECT DISTINCT t.tid, t.title, t.last_poster_name, t.last_poster_id, t.starter_id, t.starter_name, t.forum_id, f.read_perms FROM ".$ipb_table_prefix."topics t INNER JOIN ".$ipb_table_prefix."forums f ON t.forum_id = f.id where {$forum_string} ORDER BY t.last_post DESC LIMIT ".$ipb_limit, $ipb_db_connection);
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:24 PM.


Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.