Jump to content

Select count from table column within last 3 days


the_toolman

Recommended Posts

Hi,

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;

Could anyone help me with the query?

This is a screenshot of the table in phpmyadmin:

https://ibb.co/p34mxDd

Edited by cyberRobot
added code tags / removed text background
Link to comment
Share on other sites

14 minutes ago, the_toolman said:

I also don’t know how to select them based on a time period of 3 days

Neither do we without knowing your table structure.

Your select query syntax is completely screwed. You need to use a WHERE clause to conditionally select data. You also need to check the PHP manual for examples of to process your queries. (There is a SQL tutorials link in my sig)

The mysql_ functions you are using no longer exist in PHP and were deprecated years ago. You should now be using the mysqli (improved) or PDO. (PDO is highly recommended over mysqli)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.