PHP Code:
$db->query("SELECT t.id FROM `users themes` ut LEFT JOIN `themes` t ON ut.themeid = t.id WHERE ut.userid = '{$user->id}' ORDER BY date ASC");
// loops theme ID to create OR 'theme' =
while($foo = $db->fetch()){
if(!isset($var)){
$query = "`theme` = '".$foo['id']."'";
$var = 1;
} else
$query .= " OR `theme` = '".$foo['id']."'";
}
$db->query("SELECT slug, title from `forum topics` WHERE $query ORDER BY date ASC");
Basically the first query checks a table for rows that match the userid, and then the second query uses the matching corresponding themeid's to grab forum topics.
This works but I feel cheap. Is their a better solution?