I'm working with a mysql date column called 'class_of' that has dates ranging from 2014-08-01 to 2019-08-01, all formatted as a date. These dates coincide to what year an article was written.
I have set up my php execution page to grab the year through a url action. for example - www.mywebsite.com/mypage.php?action=2016
$classOf = ($_GET["action"]);
I now need to somehow use said variable within a mysql query so my php while loop will only echo dates that have for example 2016 within the date.
This is what I have tried
This works, but I need the year to be a variable
$query = 'SELECT * FROM news_content
WHERE
hot = "false"
AND trash="false"
AND class_of = DATE("2020-08-01")
ORDER BY article_id DESC';
I have tried the below, but with no success
$query = 'SELECT * FROM news_content
WHERE
hot = "false"
AND trash="false"
AND class_of = DATE("<?php echo $classOf ?>-08-01")
ORDER BY article_id DESC';
And
$query = 'SELECT * FROM news_content
WHERE
hot = "false"
AND trash="false"
AND class_of = "<?php echo $classOf ?>" ORDER BY article_id DESC';
And
$query = 'SELECT * FROM news_content
WHERE
hot = "false" AND trash="false"
AND class_of
LIKE "%<?php echo $classOf ?>%" ORDER BY article_id DESC
And
$query = 'SELECT *
FROM news_content
WHERE
hot = "false" AND trash="false"
AND class_of =
"<?php date("echo $classOf-08-01")?>" ORDER BY article_id DESC';
All of the above no success.