Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8479883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:09:24+00:00 2026-06-10T19:09:24+00:00

I trying to make tag cloud system and i enter the tags in one

  • 0

I trying to make tag cloud system and i enter the tags in one table with “name” and “product_id”.
I make that may have multiple same tags everyone for different product.
My problem is that when echo the tags from the table it show me all tags,this is good,but the repeated tags are in that count. I need to echo repeated tags only once, but i don’t know how to make that.
Here is and my code that showed and repeated tags.

$id     = $_GET['catid'];
$sql    = "SELECT * FROM tags_group";
$result = mysql_query($sql) or die(mysql_error());
while ($row    = mysql_fetch_array($result)) {
    //echo $row['name'];
    $id      = $row['id'];
    $sql1    = "SELECT * FROM tags WHERE tag_group='$id'";
    $result1 = mysql_query($sql1);
    while ($row1    = mysql_fetch_array($result1)) {
        $name   = $row1['tag_name'];
        $sql2   = "SELECT * FROM tags WHERE tag_name='$name'";
        $resut2 = mysql_query($sql2);
        $rows   = mysql_num_rows($resut2);

        echo $row1['tag_name'] . '(' . $rows . ')' . '<br>';


        // echo $row1['tag_name'].$rows.'<br>';
    }
    echo '<br>';
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:09:25+00:00Added an answer on June 10, 2026 at 7:09 pm

    You have to use the DISTINCT keyword do avoid duplicates:

    SELECT DISTINCT * FROM tags_group
    

    As I mentioned in the comments above, you should stop using mysql_* functions. They’re being deprecated. Instead use PDO (supported as of PHP 5.1) or mysqli (supported as of PHP 4.1). If you’re not sure which one to use, read this article.

    UPDATE

    It also looks like you’re using nested queries, rather than joining your tables and retrieving the results. Try this instead:

    $id     = $_GET['catid'];
    $sql    = "SELECT tags.tag_name, count(*) AS name_count FROM tags
                   INNER JOIN tags_group
                   ON tags.tag_group = tags_group.id
                   GROUP BY tag_name";
    $result = mysql_query($sql) or die(mysql_error());
    while ($row    = mysql_fetch_array($result)) {        
        $name   = $row['tag_name'];
        $rows   = $row['name_count'];
    
        echo $name . '(' . $rows . ')' . '<br>';
    
    
        // echo $row['tag_name'].$rows.'<br>';
    }
    echo '<br>';
    

    Here I don’t use DISTINCT but GROUP BY allows you to aggregate the count for each distinct row (based on the GROUP BY column).

    Take a look at this diagram to better understand how joins work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make 3 table tags system. I have 3 table in
I am trying to make a table that contains HTML tags, but when I
I'm trying to make a tag system like the one here but if the
I have a little tag cloud that shows the last 20 searches and I
I'm trying to make a little tag list doohickey for adding and removing tags.
I'm looking to make a Tag Cloud in Objective-C, and I'm trying to find
I'm trying to make a js code that works with multiple pages. I'm trying
I'm trying to make a tag that behaves differently based on the route, but
I have been trying to make a image in tag clickable without surrounding it
I have been trying to make something like Facebook @tagged Friend name add in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.