Basicly have this PHP and then two templates, the bit, for each result and the mainone to house them all:
PHP Code:
$threadquery=$DB_site->query("SELECT threadid,title,replycount FROM thread");
while ($threadinfo = $DB_site->fetch_array($threadquery)) {
$title = unhtmlspecialchars($threadinfo['title']);
$replycount = $threadinfo['replycount'];
$threadid = $threadinfo['threadid'];
eval("\$threadbits .= \"".gettemplate('query_bit')."\";");
}
eval("\$threads = \"".gettemplate('query')."\";");
Change query_bit and query in the eval statements to your template names