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 8512701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:21:15+00:00 2026-06-11T04:21:15+00:00

I want to retrieve some tags from my database, they are in the form:

  • 0

I want to retrieve some tags from my database, they are in the form:

topic_id       tags
   1        `tag1,tag2,tag3`
   2        `tag1,tag4,tag5`
   3        `tag2,tag4,tag5`
   4        `tag6,tag7,tag2`

I want to have something like this:

tag1 tag2 tag3 tag4 tag5 tag6 tag7

i.e all unique tags

So that I can wrap each tag in a link in order to group news articles that has such specific tags.

This following query I’ve written so far is not working:

$tags = mysql_query("SELECT tags, topic_id
                       FROM forum_topics
                       WHERE topic_id > 0")  or die (mysql_error());
                    while($tag = mysql_fetch_assoc($tags)){   
                    $split_tags  = "$tag";
                    $pieces = explode(",", $split_tags);
                    echo $pieces ;

When I did print_r($pieces);

I got Array ( [0] => Array ) Array ( [0] => Array ) Array ( [0] => Array ) Array ( [0] => Array )

Which was not what I was looking for.

As it is now my table structure looks like this topic_id , topic_head, topic_body, topic_tag, topic_date, topic_owner .. How can I further make the topic_tag normal.

  • 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-11T04:21:17+00:00Added an answer on June 11, 2026 at 4:21 am

    If you normalize your database design, then you could get all the distinct tags very easy by

    SELECT DISTINCT tags FROM forum_topics WHERE topic_id > 0
    

    But now, with your database structure, you can’t do this, you have to get all the tags and use array_unique on them.

    $tags = array();
    $rows = mysql_query("SELECT tags FROM forum_topics WHERE topic_id > 0")  or die (mysql_error());
    while($row = mysql_fetch_assoc($rows)){   
      $tags = array_merge($tags, explode(',' $row['tags']));
    }
    $tags = array_unique($tags);
    print_r($tags);
    

    But even you could do this, normalize your database design is the best choice.

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

Sidebar

Related Questions

I have created a database and i want to retrieve some data from the
I want to serialize some information I retrieve from the user in a small
I want to count the number of transactions which retrieves some reports from database
I have multiple CTEs and I want to retrieve some information from a couple
I have a Silverlight application that needs to retrieve some data from my database.
I want to read/retrieve some details from a single YouTube video using: $sxml= simplexml_load_file(http://gdata.youtube.com/feeds/api/videos/gzDS-Kfd5XQ);
I want to retrieve some values from my url and post them in a
I am trying to retrieve some items from local storage, and if they are
I want to retrieve some data items from a web page. Link of webpage:
i want to retrieve some data from this website: http://sites.target.com/site/en/spot/search_results.jsp?&mapType=enhanced&startAddress=72756&startingLat=36.322757720947266&startingLong=-93.99922943115234&_requestid=2573952 There are following lines

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.