PHP 将库存合并到表中
希望这是一个快速且容易回答的问题。
我有一个包含以下字段的 MySQL 数据库: shoe_size
和 waist_size
shoe_size
条目的范围为 3 到 21(按一半递增 - 3、3.5、4、4.5 等)。
waist_size
条目也是如此。
我的问题是这样的:
使用 PHP,我怎样才能最好地将其合并到一个计算尺寸总数的表格中,以便它本质上可以用作订单表格 ?
例如,MySQL 表如下所示:
----------------------------------------------
| Name | shoe_size | waist_size |
----------------------------------------------
| John | 9.5 | 33 |
----------------------------------------------
| Steve | 9 | 32 |
----------------------------------------------
| Tom | 9.5 | 33 |
----------------------------------------------
| Sally | 7 | 8 |
----------------------------------------------
| Jane | 7 | 8 |
----------------------------------------------
输出 HTML(表?)将如下所示:
ORDER FORM
------------------------------------------
| Shoe Size | 7 | 9 | 9.5 |
------------------------------------------
| Total Pairs | 2 | 1 | 2 | <----- This is calculated from above
------------------------------------------
------------------------------------------
| Waist Size | 8 | 32 | 33 |
------------------------------------------
| Total Pairs | 2 | 1 | 2 | <----- This is calculated from above
------------------------------------------
我什至不确定“订单表格”表的格式是否是执行此操作的最佳方式。任何朝着正确方向的推动将不胜感激。
Hopefully this is a quick and easy question to answer.
I have a MySQL Database with the following fields:shoe_size
and waist_size
The shoe_size
entries range anywhere from 3 to 21 (incrementing by halves-- 3, 3.5, 4, 4.5, etc).
The same is true for the waist_size
entries.
My question is this:
Using PHP, how can I best consolidate this into a table that counts the total number of sizes, so that it could essentially be used as an Order Form?
For example, the MySQL table looks like this:
----------------------------------------------
| Name | shoe_size | waist_size |
----------------------------------------------
| John | 9.5 | 33 |
----------------------------------------------
| Steve | 9 | 32 |
----------------------------------------------
| Tom | 9.5 | 33 |
----------------------------------------------
| Sally | 7 | 8 |
----------------------------------------------
| Jane | 7 | 8 |
----------------------------------------------
And the output HTML (table?) would look something like this:
ORDER FORM
------------------------------------------
| Shoe Size | 7 | 9 | 9.5 |
------------------------------------------
| Total Pairs | 2 | 1 | 2 | <----- This is calculated from above
------------------------------------------
------------------------------------------
| Waist Size | 8 | 32 | 33 |
------------------------------------------
| Total Pairs | 2 | 1 | 2 | <----- This is calculated from above
------------------------------------------
I'm not even sure if my format for the "Order Form" table is the best way to go on this. Any nudge in the right direction would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MySQL 可能足以完成此任务,尝试类似的方法
MySQL might be enough for this task, try something like
我认为您正在寻找的是 GROUP BY。
(http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html)
例如:
I think what you are looking for is GROUP BY.
(http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html)
e.g: