如何每月从mysql创建表报告

时间:2019-05-21 09:26:09

标签: php mysql mysqli report

我正在尝试从MySQL创建月度报告,这是我到目前为止所获得的。

https://imgur.com/ShNJ0Ya“表格”

代码:

      <table id="tablePreview" class="table table-hover table-sm table-bordered" style="border-top: 0px solid hsl(0, 0%, 87%);">


        <thead style="color:black; background-color: hsla(0,0%,71%,1.00); border-top: 0px solid hsl(0, 0%, 87%);">
            <tr>
                <th scope="col">Datum</th>
                <th scope="col">Projekt</th>
            </tr>
        </thead>
        <tbody>
            <?php while ($zapasytb = mysqli_fetch_assoc($query)) { ?>
            <tr>
                <td>
                    <?=date("d.m.Y", strtotime($zapasytb['datum']));?>
                </td>
                <td>
                    <?php if($zapasytb['projekt'] == 0)
                                    {echo "TipSport"; }
                                        elseif($zapasytb['projekt'] == 1)
                                    {echo "Slavia";
                                                                         }
                                        elseif($zapasytb['projekt'] == 2 ){
                                    echo "Bet";}?>
                </td>
            </tr>
            <?php } ?>
        </tbody>
    </table>

查询:

   $query = mysqli_query($conn, "SELECT * FROM zapasy WHERE komentator1 = '$firstname $lastname' OR komentator2 = '$firstname $lastname'");

数据库:

zapasy
   -id
   -datum
   -projekt
   -komentator1
   -komentator2

我想制作一张像这样的桌子:

Months | Bet | TipSport | Slavia
--------------------------------
January | 5   |    10    |   7  
February| 1   |     7    |   12

我真的很感谢任何建议。

0 个答案:

没有答案