I have a table called tags which contains the tag_name and the question_id. Just like Stack Overflow, I can insert each tags by exploding them with a comma. That works.
But I also wanted to show all the tags. Let's say this is the result I get after selecting it from the tags table.
Array (
[0] => Array (
[tag_name] => tag-1,
[question_id] => 1
)
[1] => Array (
[tag_name] => tag-1,
[question_id] => 2
)
[2] => Array (
[tag_name] => tag-2,
[question_id] => 3
)
)
When I iterate through them, I get
tag-1
tag-1
tag-2
But that's not how I wanted it. I was thinking of something like
tag-1 × 2
tag-2
How can I achieve that? I'm using CodeIgniter but it doesn't really matter, because I only want to understand the logic of it.
Thanks in advance.
COUNT()them and do a GROUP BY ;-) maybe even using HAVING in conjunction withCOUNT(). That would work.