It sounds like you would be better off just grabbing all of the threadids from the post table and then counting those using a PHP loop, without any additional queries.
Something like:
PHP Code:
$allthreads = $DB_site->query("SELECT threadid FROM post WHERE site='2'");
while ($eachthread = $DB_site->fetch_array($allthreads))
$thread_table[$eachthread[threadid]]++;
foreach ($thread_table as $k => $v)
echo "threadid $k has $v entries<br>";
That would output a list of how many posts are in each thread that matches site=2. Basically, the same thing that your original code did, but with a single query.