I'm new to MySQL, so I've gotten a bit confused here. What I'm doing right now is calling a Mysql query that fetches data from a table where a keyword is matched. The code is right here:
public function fetch_tags($tag) {
global $pdo;
$query = $pdo->prepare("SELECT * FROM `articles` WHERE `article_tags` LIKE '%$tag%' OR `article_content` LIKE '%$tag%'");
$query->execute();
return $query->fetch();
}
The problem is that say the keyword passed in first is "Michael", and then the next one is "Dekstra," both of these will return the exact same row because they are the first and last name of the same person. I don't want to fetch the same result twice though. How can I make it so that once a particular result has been fetched, the next query won't go in to get the same result again. They need to be different every single time. I want them ordered from newest to oldest.
Any help is much appreciated. I feel really lost.