how I can create a query that searches for matching tags, I don’t want to have to query every article everytime someone clicks a tag. can anyone help? my initial thoughts were to create a row in the table where the articles are stored, named tags, and list the tags seperated by commas,
am using the PHP implode function
$tagsArray = implode(", ", $gameTags);
to insert tags into my gaming table
like you see in the image below what I want is to get back just one tag from the game_tag table like MMORPG tag or strategy tag to be able to show just let’s say strategy game in the strategy games page.
right now am using this code to get tags from the table
function getStrategyGames($conn){
$getGame = “SELECT * FROM browserGames”;
if ($stmt = $conn->prepare($getGame)) {
if ($stmt->execute()) {
if ($stmt->rowCount() > 0) {
$result = $stmt->fetch();
$gameTag = explode(’,’, $result[‘game_tag’]);
foreach($gameTag AS $single):
echo $single . “
”;
endforeach;
}
}
}
}
the code above echo out all the tags i want way to echo out just the first element in the array or the second and so on.
thanks for help