the_toolman Posted July 6, 2019 Share Posted July 6, 2019 (edited) 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 July 16, 2019 by cyberRobot added code tags / removed text background Quote Link to comment https://forums.phpfreaks.com/topic/308933-select-count-from-table-column-within-last-3-days/ Share on other sites More sharing options...
Barand Posted July 6, 2019 Share Posted July 6, 2019 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) Quote Link to comment https://forums.phpfreaks.com/topic/308933-select-count-from-table-column-within-last-3-days/#findComment-1568174 Share on other sites More sharing options...
MPM Posted July 8, 2019 Share Posted July 8, 2019 Make sure you have error reporting turned on as you should be seeing errors with that code. Quote Link to comment https://forums.phpfreaks.com/topic/308933-select-count-from-table-column-within-last-3-days/#findComment-1568209 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.