Code:
SELECT forums.name AS `forum_name`
, topics.title
, topics.title
, topics.tid
, COUNT(*) AS posts_read
FROM forums
INNER
JOIN topics
ON topics.fid = forums.fid
INNER
JOIN ( SELECT tid
, MAX(time) AS latest_view_time
FROM views
WHERE uid = $uid -- selected user
GROUP
BY tid ) AS v
INNER
JOIN views
ON views.tid = v.tid
AND views.time = v.latest_view_time
AND views.uid = $uid -- selected user
INNER
JOIN posts
ON posts.tid = views.tid
AND posts.time <= views.time
WHERE forums.fid = 5
GROUP
BY topics.tid
Bookmarks