[英]Data Table Grouped / Separated by Date
I have MySQL Table我有 MySQL 表
id ![]() |
date![]() |
name![]() |
files![]() |
---|---|---|---|
1 ![]() |
2021-10-11 12:00:00 ![]() |
OG Loc![]() |
God Rap![]() |
2 ![]() |
2021-10-11 12:00:00 ![]() |
Ryder![]() |
God Weedo![]() |
3 ![]() |
2021-10-10 12:00:00 ![]() |
Carl![]() |
God Child![]() |
4 ![]() |
2021-10-10 12:00:00 ![]() |
Johnson![]() |
God Cheat![]() |
5 ![]() |
2021-10-10 12:00:00 ![]() |
Big Smoke![]() |
God Crackzz![]() |
6 ![]() |
2021-10-9 12:00:00 ![]() |
Sweet![]() |
God Brother![]() |
What i want to archive is, the data printed with PHP on table and separated / grouped by date:我要存档的是,在表格上用PHP打印并按日期分隔/分组的数据:
# ![]() |
Ticket(id)![]() |
Date![]() |
Name![]() |
Files![]() |
---|---|---|---|---|
2021-10-11 ![]() |
||||
1 ![]() |
1 ![]() |
2021-10-11 12:00:00 ![]() |
OG Loc![]() |
God Rap![]() |
2 ![]() |
2 ![]() |
2021-10-11 12:00:00 ![]() |
Ryder![]() |
God Weedo![]() |
2021-10-10 ![]() |
||||
3 ![]() |
3 ![]() |
2021-10-10 12:00:00 ![]() |
Carl![]() |
God Child![]() |
4 ![]() |
4 ![]() |
2021-10-10 12:00:00 ![]() |
Johnson![]() |
God Cheat![]() |
5 ![]() |
5 ![]() |
2021-10-10 12:00:00 ![]() |
Big Smoke![]() |
God Crackzz![]() |
2021-10-09 ![]() |
||||
6 ![]() |
6 ![]() |
2021-10-9 12:00:00 ![]() |
Sweet![]() |
God Brother![]() |
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body class="container mt-2">
<?php
$date=array();
$cars = array("2021-04-25","2021-04-26","2021-04-27","2021-04-25","2021-04-26","2021-04-25");
$date=array_unique($cars);
$no=1;
?>
<table class="table table-bordered">
<tr>
<th>No</th>
<th>Date</th>
</tr>
<?php
foreach($date as $d)
{
?>
<tr>
<th colspan=2><?php echo $d; ?></th>
</tr>
<?php
foreach($cars as $c)
{
if($d == $c)
{
?>
<tr>
<th><?php echo $no; ?></th>
<th><?php echo $c; ?></th>
</tr>
<?php
$no++;
}
}
}
?>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.