Counting occurrences of data
Posted: Tue Aug 22, 2006 7:22 am
I have been reading a lot and I'm more confused then at the beginning.
I have a table into which I put posts.
There are rows for the post id, title, text, date and a row for the tags I add to the post.
The tags are separated by a comma (ex: art,web,digital).
I have many posts in the database, sometimes the tags are repeated.
I need to know how many of a certain tags there are (to make a tag cloud. For example: how many "web" tags I have?).
Is there a way to perform a count with the data stored like that or I have to store the data in a different way? If the latter is true, how?
I use php to display the data.
So far I can get all the tags into an array, use array_unique and obtain all the single tags used, but to count how many times each of them occurs, I'm going mental!! Tried substr_count but "web" gets counted twice if there is a "website" tag. So I thought maybe I can do it using MySQL commands. Anybody knows how?
Thanks
I have a table into which I put posts.
There are rows for the post id, title, text, date and a row for the tags I add to the post.
The tags are separated by a comma (ex: art,web,digital).
I have many posts in the database, sometimes the tags are repeated.
I need to know how many of a certain tags there are (to make a tag cloud. For example: how many "web" tags I have?).
Is there a way to perform a count with the data stored like that or I have to store the data in a different way? If the latter is true, how?
I use php to display the data.
So far I can get all the tags into an array, use array_unique and obtain all the single tags used, but to count how many times each of them occurs, I'm going mental!! Tried substr_count but "web" gets counted twice if there is a "website" tag. So I thought maybe I can do it using MySQL commands. Anybody knows how?
Thanks