I was wondering how can I check if there is no tags entered into the database for a specific post if there are none, display no tags have been entered
. How can I do this using PHP?
Here is my PHP & MySQL code.
$tag = array();
$dbc = mysqli_query($mysqli, "SELECT tags.tag
FROM posts_tags
INNER JOIN tags ON tags.id = posts_tags.tag_id
WHERE posts_tags.post_id = '" . $post_id . "'
GROUP BY tags.tag");
if (!$dbc) {
print mysqli_error($mysqli);
} else {
while($row = mysqli_fetch_array($dbc)){
$tag[] = $row['tag'];
}
}