SalientAnimal Posted June 25, 2012 Share Posted June 25, 2012 Hi All, I am runningt his query to count and then display the current date's records captured. Even thoguh I know there are records captured, why am I still getting no results? $result = mysql_query("SELECT * FROM cs_2012 WHERE sys_date = CURRENT_DATE()"); $num_rows = mysql_num_rows($result); echo "$num_rows Rows\n"; Quote Link to comment Share on other sites More sharing options...
requinix Posted June 25, 2012 Share Posted June 25, 2012 If you're getting no results then there aren't any records being "captured". Try running your query using some tool like phpMyAdmin or MySQL Workbench. Quote Link to comment Share on other sites More sharing options...
SalientAnimal Posted June 25, 2012 Author Share Posted June 25, 2012 If you're getting no results then there aren't any records being "captured". Try running your query using some tool like phpMyAdmin or MySQL Workbench. I've run the query using a like function and then using today's date and I am getting results, however, I don't want to have to update the query everyday. $result = mysql_query("SELECT * FROM cs_2012WHERE sys_date = like '2012-06-25%'");$num_rows = mysql_num_rows($result);echo "$num_rows Rows\n"; The above query returns 270 Rows. But when using CURDATE() or CURRENT_DATE() it says 0 Rows Quote Link to comment Share on other sites More sharing options...
SalientAnimal Posted June 25, 2012 Author Share Posted June 25, 2012 Ok, so I finally after lots of trial nad error got this to work. I can only assume that the reason I wasn't getting any results is because my sys_date column is a TIMESTAMP field. Here's the solution: $result = mysql_query(" SELECT * FROM cs_2012 WHERE DATE(sys_date) = CURDATE() "); $num_rows = mysql_num_rows($result); Quote Link to comment 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.