$threads = $vbulletin->db->query_read(" SELECT * FROM " . TABLE_PREFIX . "thread WHERE forumid = X ORDER BY dateline DESC LIMIT 5");while ($thread = $vbulletin->db->fetch_array($threads)){ // thread data is in $thread}