Actually, your SELECT statement pulls posts in a thread, which happens to include the author information. That doesn't do anything for you. You need to figure out how many posts each user has made. You could do SELECT count(*), but depending on the number of users in the thread, that could take FOREVER.
I suggest that you create a column called "post_count" in the user table (or better yet, a separate table with post_count and user_id columns). That way all you have to do is pull the post_count value and use this, which is almost identical to drawmack's:
$sql = "SELECT max(r.num_posts), r.rankname " .
"FROM u_ranks u, ranks r " .
"WHERE u.post_count >= r.num_posts " .
"AND u.id = '$userid' " .
"GROUP BY r.num_posts";
(code untested... try it out yourself)