我如何才能基于下一行在PHP或MYSQL的输出来输入条目

时间:2018-07-03 03:39:46

标签: php sql

我有一张表格,显示日期和数量。我想继续显示日期,但是如果1天没有数据,则假设日期为星期五,它将显示(sat | 0)。

|day|qty|
|mon| 1 |
|wed| 3 |
|thu| 4 |
|fri| 5 |
|mon| 1 |
|tue| 2 |
|wed| 3 |
|thu| 4 |
|fri| 5 |
|sat| 6 |
|mon| 1 |
|tue| 2 |
|wed| 3 |
|thu| 4 |
|fri| 5 |
|sat| 6 |
|sat| 7 |

输出应如下所示

|day|qty|
|mon| 1 |
|tue| 0 | -->> added row
|wed| 3 |
|thu| 4 |
|fri| 5 |

|sat| 0 |   ->>> added row
|sun| 0 |    ->> added row

|mon| 1 |
|tue| 2 |
|wed| 3 |
|thu| 4 |
|fri| 5 |
|sat| 6 |

|sun| 0 |   ->> added row

|mon| 1 |
|tue| 2 |
|wed| 3 |
|thu| 4 |
|fri| 5 |
|sat| 6 |
|sun| 7 |

0 个答案:

没有答案