我有一个 Orders 项目,我想在其中实现标签打印。每个订单必须根据其物品数量显示标签数量。到目前为止,我已经设法用“for”来显示数量。
数据库示例:
+-------+-------------+-----+
| order | description | qty |
+-------+-------------+-----+
| 1 | stickers | 1 |
| 2 | posters | 2 |
| 2 | tape | 1 |
| 2 | (no desc) | 1 |
+-------+-------------+-----+
到目前为止我所拥有的:
Select SUM(qty) AS pieces FROM mytable WHERE order = '2'");
$total=$row['pieces']; //this correspond to all items on the order.
for ($x = 1; $x <= $row_count; $x++){
echo $order."<br>"; //order number
echo $x."<br>"; //item
echo $total."<br>"; //total items
}
结果:
#order #item #total #order #item #total
+-------+-------+-------+ +-------+-------+-------+
posters | 2 | 1 | 4 | | 2 | 2 | 4 |
+-------+--- ---+-------+ +-------+-------+-------+
#order #item #total
+-------+-------+-------+
tape | 2 | 3 | 4 |
+-------+-------+-------+
#order #item #total
+-------+-------+-------+
(no desc) | 2 | 4 | 4 |
+-------+-------+-------+
但是我无法显示每个“描述”栏的内容。
理想的结果:
#order #desc #item #total #order #desc #item #total
+---+--------+----+----+ +---+--------+----+----+
posters | 2 | posters| 1 | 4 | | 2 | posters| 2 | 4 |
+---+--------+----+----+ +---+--------+----+----+
#order #desc #item #total
+---+--------+----+----+
tape | 2 | tape | 3 | 4 |
+---+--------+----+----+
#order #desc #item #total
+---+---------+----+----+
(no desc) | 2 |(no desc)| 4 | 4 |
+---+---------+----+----+
有机会得到这个结果吗?我正在使用 php 和 mysql。
慕妹3146593