I have user entered tags that go under the table field tags.
$sql="SELECT tags from table";
$stmt16 = $conn->prepare($sql);
$result=$stmt16->execute();
while($row = $stmt16->fetch(PDO::FETCH_ASSOC)){
echo $tags=$row['tags'];
}
This produces
cool,yes,okcool,yes,ok
because there are 2 entries with the same 3 tags under that field. I want to be able to count how many duplicates there are of each tag such that the result should be cool(2) yes(2) ok(2). Anyone know the proper way to approach this? Should I fetch the results as an array or explode them?
With your current data structure, the answer I’d give is yes: as you said, explode them, and put them into an array.
However, if you can change the database structure, you’ll find it a lot easier to manage your tags if you only have one per DB record. It will make it a lot easier to query them that way.