What is $excludedthreads ? I'm assuming it contains "WHERE" - so make sure that its either always there or make it that way.
Here would be the condition to limit it to certain forums: [sql]thread.forumid IN (1, 2, 3)[/sql] and to exclude: [sql]NOT (thread.forumid IN (1, 2, 3))[/sql]You're probably best off loading them into an array and imploding them inside the query
PHP Code:
$forums = array(1, 2, 3, ...);
$forumlist = implode(',', $forums);
then use [sql]thread.forumid IN ($forumlist)[/sql]