需要从MySQL数据库中获取今天的结果

时间:2017-08-23 19:29:23

标签: php mysql

所以,我试图向那些为我工作的人展示他们当天做了多少......无论如何你可以告诉我为什么这只给了我一个" 0&#34 ;返回?

$sql = "
SELECT SUM(money_earned) as money_earned 
  FROM staff_pay 
 WHERE DATE(time_charged)=CURDATE() 
   AND staff_id={$_SESSION['staff_id']}
";

1 个答案:

答案 0 :(得分:-1)

试试这个

$sid = $_SESSION['staff_id'];
$sql = "
SELECT  SUM(money_earned) as money_earned 
FROM staff_pay 
WHERE DATE(time_charged)=CURDATE() 
AND staff_id=$sid";