MySQL数据库表:(名称:出席)
RecID | EmployeeID | Date | Name | WorkedHours | Absence | OverTime
------+------------+----------+------+-------------+---------+---------
434 | 7 | 19/11/16 | Jack | 8 | | 1
435 | 7 | 20/11/16 | Jack | 8 | | 0
436 | 7 | 21/11/16 | Jack | 8 | | 0
437 | 8 | 19/11/16 | Nik | 8 | | 1
438 | 8 | 20/11/16 | Nik | 0 | 1 | 0
439 | 8 | 21/11/16 | Nik | 8 | | 1
我想使用PHP显示以下工资报告:
EmployeeID | Month | Name | WorkedDays| Deductions| Overtime | Net Pay
-----------+-------+------+-----------+-----------+----------+--------
7 | 11/16 | Jack | 3 | | | 1
8 | 11/16 | Nik | 2 | | | 0
到目前为止,我使用 SQL :
进行了以下尝试SELECT EmployeeID, Name,
COUNT(*) AS WorkedDays,
(COUNT(*) * $DailyWage) AS 'Net Pay'
FROM `Attendance`
GROUP BY EmployeeID;
有没有办法通过 PHP 循环实现这一目标?像
这样的东西$SQL = mysql_query("SELECT * FROM Attendance GROUP BY EmployeeID");
while($Row = mysql_fetch_array($SQL)){
$WorkedDays++;
echo "WorkedDays: " . $WorkedDays;
// Doesn't make sense but just giving example.
}
如果您需要任何细节,请告诉我。谢谢。