Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP将库存合并到表中_Php_Mysql_Tabular_Inventory - Fatal编程技术网

PHP将库存合并到表中

PHP将库存合并到表中,php,mysql,tabular,inventory,Php,Mysql,Tabular,Inventory,希望这是一个快速而容易回答的问题 我有一个MySQL数据库,其中包含以下字段: 鞋码和腰围 shoe_size条目的范围从3到21不等(增加一半——3、3.5、4、4.5等) 对于腰围尺寸条目也是如此 我的问题是: 使用PHP,我如何才能最好地将其整合到一个统计大小总数的表中,以便它基本上可以用作一个订单 例如,MySQL表如下所示: ---------------------------------------------- | Name | shoe_size

希望这是一个快速而容易回答的问题

我有一个MySQL数据库,其中包含以下字段:
鞋码
腰围

shoe_size
条目的范围从3到21不等(增加一半——3、3.5、4、4.5等)

对于
腰围尺寸
条目也是如此

我的问题是:

使用PHP,我如何才能最好地将其整合到一个统计大小总数的表中,以便它基本上可以用作一个订单

例如,MySQL表如下所示:

  ---------------------------------------------- 
  |     Name    |   shoe_size   |  waist_size  |
  ----------------------------------------------
  |      John   |      9.5      |      33      |
  ----------------------------------------------
  |     Steve   |       9       |      32      |
  ----------------------------------------------
  |     Tom     |      9.5      |      33      |
  ----------------------------------------------
  |    Sally    |       7       |       8      |
  ----------------------------------------------
  |    Jane     |       7       |       8      |
  ----------------------------------------------
                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
  ------------------------------------------
输出的HTML(表格?)如下所示:

  ---------------------------------------------- 
  |     Name    |   shoe_size   |  waist_size  |
  ----------------------------------------------
  |      John   |      9.5      |      33      |
  ----------------------------------------------
  |     Steve   |       9       |      32      |
  ----------------------------------------------
  |     Tom     |      9.5      |      33      |
  ----------------------------------------------
  |    Sally    |       7       |       8      |
  ----------------------------------------------
  |    Jane     |       7       |       8      |
  ----------------------------------------------
                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
  ------------------------------------------
订单
------------------------------------------
|鞋码| 7 | 9 | 9.5|
------------------------------------------

|总共两对| 2 | 1 | 2 |我想你要找的是分组。 (http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html)

e、 g:


MySQL可能足以完成此任务,请尝试以下操作

SELECT shoe_size, COUNT(id) as count FROM table GROUP BY shoe_size ORDER BY shoe_size asc