How to display the number of registered users today?

Made a simple function-sketch

GetTodayUsers function()
{
$today = date("Y-m-d");
$sql = mysql_query("SELECT login FROM account WHERE add_date >= '$today'") or die(mysql_error());
$row = mysql_fetch_assoc($sql);
print_r($row);
}


but displays only 1 user
July 4th 19 at 22:54
3 answers
July 4th 19 at 22:56
Solution
GetTodayUsers function()
{
$today = date("Y-m-d");
$sql = mysql_query("SELECT login FROM account WHERE add_date >= '$today'") or die(mysql_error());
while($row = mysql_fetch_assoc($sql)){
print_r($row);
}
}
July 4th 19 at 22:58
Solution
If you need is the number, like this:
SELECT COUNT(*) FROM `account` WHERE `add_date` > CURDATE()
July 4th 19 at 23:00
Solution
Use the UNIX_TIMESTAMP()
GetTodayUsers function()
{
$today = date("Y-m-d");
$sql = mysql_query("SELECT login FROM account WHERE UNIX_TIMESTAMP(add_date) >= UNIX_TIMESTAMP('".$today."')") or die(mysql_error());
$row = mysql_fetch_assoc($sql);
print_r($row);
}


Useful manual date: www.mysql.ru/docs/man/Date_and_time_functions.html

Find more questions by tags MySQLPHP