I have a database which stores listings in 2 main categories.
I am trying to select the total number of listings in each of the categories with term_taxonomy_id’s of 109 and 110 that have been added within the last 3 days.
This is what I have so far, but it’s not showing anything when echoing. I also don’t know how to select them based on a time period of 3 days
$total_competitions = mysql_query("SELECT COUNT(term_taxonomy_id=109) FROM wp_term_taxonomy;");
echo $total_competitions;
And what happens instead? Remember: no one here sits in front of your screen, everything you do is a blank page for us, except for the things you tell us. you should at least throw exceptions on your testing system: mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
You need to look at the various fetch functions if you want to actually retrieve the data - $result is an object that contains those rows, or a reference to them at least. So you’d do something like
while ($row = mysqli_fetch_array($result) {
echo $row['taxonomy'];
}