我有一个查询,当我打印一个表格时,它给了我类似以下的结果:
+---------------------------------------------------------------------+
| ID | Name | Color | Size | Qty |
+---------------------------------------------------------------------+
| 1 | First | Green | S | 1 |
| 2 | First | Green | L | 2 |
| 3 | First | Green | XL | 1 |
| 4 | First | Red | M | 2 |
| 5 | First | Red | L | 3 |
| 6 | Second | Blue | S | 1 |
| 7 | Second | Blue | M | 4 |
+---------------------------------------------------------------------+
现在我想做一个概述(在现实生活中这些是产品),有人可以单击按钮进行编辑或删除。我想用 foreach 循环或其他东西循环它并打印出如下内容:
+========================================================================+
| Name | Color | Size | Qty | Action |
+========================================================================+
| First | Green | S | 1 | Edit|Delete |
| | | L | 2 | Edit|Delete |
| | | XL | 1 | Edit|Delete |
+------------------------------------------------------------------------+
| First | Red | M | 2 | Edit|Delete |
| | | L | 3 | Edit|Delete |
+------------------------------------------------------------------------+
| Second | Blue | S | 1 | Edit|Delete |
| | | M | 4 | Edit|Delete |
+------------------------------------------------------------------------+
但不知何故,我无法理解如何编程这个循环。还是我应该更改查询?我希望有人能帮帮忙。如果您需要更多信息,请告诉我。