I've been trying to count how many times a tag has been entered into the database and display the number of times it has been entered along with the tag into the database just like here on StackOverflow but I can't seem to be able to do it can someone help me?
So far I can get the tag but not the count.
Thanks in advance for the help!
Here is my MySQL & PHP code.
$dbc = mysqli_query($mysqli,"SELECT tags.*, posts_tags.*
FROM tags
INNER JOIN posts_tags ON tags.id = posts_tags.tag_id
GROUP BY tags.tag
ORDER BY tags.tag ASC");
if (!$dbc) {
print mysqli_error($mysqli);
}
while($row = mysqli_fetch_assoc($dbc)) {
$tag = $row['tag'];
echo '<a href="http://localhost/tags/">' . $tag . '</a>';
}