Answered: Add related tags to tag page

Post date: 2025-05-09 04:21:33
Views: 1

I changed the query to a more simple one and do the rest in php.

function get_tag_related_tags($tag) {
    $query = "
        SELECT tags
        FROM ^posts
        WHERE type='Q' AND tags LIKE CONCAT('%', # , '%')
    ";
    $results = qa_db_read_all_assoc(qa_db_query_sub($query, $tag));
    
    $tag_counts = ];
    foreach ($results as $row) {
        $tags = explode(',', $row'tags']);
        foreach ($tags as $t) {
            $t = trim($t);
            if ($t !== $tag && $t !== '') {
                if (!isset($tag_counts$t])) {
                    $tag_counts$t] = 0;
                }
                $tag_counts$t]++;
            }
        }
    }

    arsort($tag_counts);

    $related_tags = ];
    $i = 0;
    foreach ($tag_counts as $t => $count) {
        $related_tags] = 'tag' => $t, 'count' => $count];
        $i++;
        //if ($i >= 10) break;
    }

    return $related_tags;
}

Now it works.

Please click Here to read the full story.
 
Other Top and Latest Questions:
Online bettors spent over $40 million gambling on the identity of the next pope—one winner made $52,000 on a longshot
Rippling valued at $16.8 billion as HR software startup raises $450 million, says IPO not imminent
Help me get a sick cat to eat
Database problem with a plug6
¿Cómo se dice «kitty kitty kitty» en español?
brain zaps not from withdrawal
Tips for finding one-night bed and breakfasts in England at short notice
The most comfortable sheets in the world??
Answered: Add related tags to tag page
The Trump tax cut debate is heating up. Here are the key issues and who stands to benefit