View Single Post
09-21-2012, 10:18 PM
#10
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old

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?

Reply With Quote