我正在尝试完成这样的事情:http: //mediaformations.com/accordion-tables-with-jquery/但我的 HTML 表将被动态填充。
我有两张桌子:
+------------------------+
| TB_ACTIVE_USERS |
+------------------------+
| ID | NAME | EMAIL |
+------------------------+
+---------------------------+
| TB_POSTS |
+---------------------------+
|USER_ID|PDATE|SUBJECT|BODY |
+---------------------------+
这就是我想以堆叠和嵌入式 HTML 表格的形式获得的内容:
+------------------------+
| LIST OF ACTIVE USERS |
+------------------------+
| USER 1 NAME |
+------------------------+
|+----------------------+|
||DATE | SUBJECT | BODY ||
|+----------------------+|
||10/01| Lorem1 |IpsumA||
|+----------------------+|
||10/01| Lorem1B |IpsumB||
|+----------------------+|
||10/02| Lorem1C |IpsumC||
|+----------------------+|
+------------------------+
| USER 2 NAME |
+------------------------+
|+----------------------+|
||DATE | SUBJECT | BODY ||
|+----------------------+|
||10/01| Lorem2 |IpsumA||
|+----------------------+|
+------------------------+
| USER 3 NAME |
+------------------------+
|+----------------------+|
||DATE | SUBJECT | BODY ||
|+----------------------+|
||10/02| Lorem3 |IpsumA||
|+----------------------+|
||10/02| Lorem3B |IpsumB||
|+----------------------+|
+------------------------+
使用此查询:
SELECT usr.name, pdate, subject, body
FROM tb_posts
JOIN tb_active_users AS usr
ON user_id = usr.id
WHERE pdate >= CURDATE()
ORDER BY usr.name, pdate