你好,我是编程的新手,我偶然发现了按日期对数据进行分组并将其显示在带有日期分隔符的表格中的情况。
我知道如何从数据库中获取数据并将它们显示在html表中,但是按日期对数据进行分组对我来说似乎并不容易,我是php编程的初学者。我将不胜感激。
答案 0 :(得分:1)
显示输出:
键是使用数组键值。
主数组应该以{{1}}作为键,并将所有员工行附加到它。
数组结构应为:
date
代码:
Array
(
[19/04/19] => Array
(
[0] => Array
(
[id] => 1
[idno] => 111
[date] => 19/04/19
[employee] => MAYER CU
[timein] => 8:00:00 AM
[timeout] => 6:54:00 PM
[totalhours] => 10:54
)
[1] => Array
(
[id] => 2
[idno] => 111
[date] => 19/04/19
[employee] => MAYER CU
[timein] => 10:00:00 AM
[timeout] => 6:00:00 PM
[totalhours] => 8
)
)
[20/04/19] => Array
(
[0] => Array
(
[id] => 3
[idno] => 111
[date] => 20/04/19
[employee] => MIKE SMITH
[timein] => 9:01:00 AM
[timeout] => 6:54:00 PM
[totalhours] => 9:53
)
[1] => Array
(
[id] => 4
[idno] => 111
[date] => 20/04/19
[employee] => MIKE SMITH
[timein] => 10:00:00 AM
[timeout] => 6:55:00 PM
[totalhours] => 8:55
)
)
)