php - How do I calculate a payroll directly from an attendance records -
mysql database table: (name: attendance)
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
i show following payroll report using php:
employeeid | month | name | workeddays| deductions| overtime | net pay -----------+-------+------+-----------+-----------+----------+-------- 7 | 11/16 | jack | 3 | | | 1 8 | 11/16 | nik | 2 | | | 0
what tried far following using sql:
select employeeid, name, count(*) workeddays, (count(*) * $dailywage) 'net pay' `attendance` group employeeid;
is there way can through php loop? like
$sql = mysql_query("select * attendance group employeeid"); while($row = mysql_fetch_array($sql)){ $workeddays++; echo "workeddays: " . $workeddays; // doesn't make sense giving example. }
please let me know if need details. thank you.
Comments
Post a Comment