PHP redice SQL queres?

I using mybb and I am hooked to forum-display-thread which means that if in the forum there are 10 threads my code will generate 10 queries!

function tags_forumdisplay()
{
global $db, $forumtags, $thread;

$query = $db->simple_select("tags", "tags", "tid=".$thread['tid']);
$forumtags = $db->fetch_array($query);

if (!empty($forumtags['tags']))
{
$x = preg_replace('/\s*,\s*/', ', ', $forumtags['tags']);
$forumtags = $x;
}
else
{
/$forumtags = "";
}
}

How can I make turn data from tags table into a global value and then use that data to fetch tags?

Some like this:

function tags_forumdisplay_start()
{
    global $db, $tags;

    $query = $db->simple_select("tags", "tags, tid");
    $tags = $db->fetch_array($query);

}

function tags_forumdisplay_thread()
{
    global $tags, $tids;
    // $tids contains all thread tids!
// use $tags and  $tids to fetch the correct tags
}

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.