PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm very new to PHP. I'm trying count the number of registrations today and display in the web page. Below is the code I'm using but I'm unable to compare:
$today = date("Y-m-d H:i:s");
$resultCount = mysql_query("SELECT count(*) FROM users WHERE registerDate='$today' ");
With this you're counting the number of registrations in that moment(since you included hour:minute:second part), which will most of the time be equal to zero.
To get registrations count for today, you need to format both comparing values (php variable $today, and mysql registerDate value) to be the same, and to only compare date without time part
$today = date("Y-m-d"); //omited the time part
// format database date for comparing
$resultCount = mysql_query("SELECT count(*) FROM users WHERE DATE_FORMAT(registerDate, '%Y-%m-%d')='$today' ");