采购表:
========================
id|username|product|price|
01|Desmond |tv |$40 |
02|Desmond |watch |$20 |
03|Desmond |ring |$30 |
04|Desmond |laptop |$40 |
========================
产品表:
============================
id|product|type |promotion_ID|
01|tv |big |001 |
02|watch |small|002 |
03|ring |small|002 |
04|laptop |big |001 |
============================
促销编号:
==============================
id|promotion_ID|promotion_name|
01|001 |mid-year |
02|002 |end-year |
==============================
我想基于 while 循环方法显示采购表的结果,以显示来自 mysql 的所有信息,这没问题,但我想根据采购表的促销 ID/促销名称对它们进行分组。我可以知道,我该怎么做?
例如显示结果:
年中
=======================
username|product|price|
Desmond |tv |$40 |
Desmond |laptop |$40 |
=======================
年终
=======================
username|product|price|
Desmond |watch |$20 |
Desmond |ring |$30 |
=======================