没有生成任何内容时折叠表

时间:2017-06-02 12:52:53

标签: php jquery css html-table

使用这个PHP代码,我生成一个表。来自数据库的内容。现在我想要崩溃它,如果它没有生成任何内容。

它只是表格的一部分,否则会有很多代码。表的其余部分是相同的。

  <table class="table">
      <tr class="day">
        <th>
        <?php
          $j = 0;
          thisDayIs($weekDays[$j]);
          echo "<br>";
          echo $weekDays[$j];
          $j++;
         ?>
        </th>
        <?php
          $datum = $weekDays[$j];

          $parameters = array(':date'=>$datum,
                              ':aid'=>$id);
          $sth = $pdo->prepare("SELECT DISTINCT opdrachten.KRITISCHE_DATUM, opdrachten.PLANNINGS_DATUM, opdrachten.OPDRACHTID, onderzoekactiviteiten.A_UITVOERDER
                                FROM opdrachten
                                INNER JOIN onderzoekactiviteiten
                                ON opdrachten.OPDRACHTID=onderzoekactiviteiten.OPDRACHTID
                                WHERE PLANNINGS_DATUM = :date
                                AND A_UITVOERDER = :aid");
          $sth->execute($parameters);
          while ($row = $sth->fetch())
          {
            $cutKritDate = substr($row['KRITISCHE_DATUM'], 0, 10);
            $cutPlanDate = substr($row['PLANNINGS_DATUM'], 0, 10);
            echo "<td>Krit= " . $cutKritDate . "<br>";
            echo "Plan= " . $cutPlanDate . "<br>";
            echo "Opdracht= " . $row['OPDRACHTID'] . "</td>";
          }

        ?>
      </tr>


      <tr class="day">
        <th>
        <?php
          thisDayIs($weekDays[$j]);
          echo "<br>";
          echo $weekDays[$j];
          $j++;
        ?>
        </th>
        <?php
          $datum = $weekDays[$j];

          $parameters = array(':date'=>$datum,
                              ':aid'=>$id);
          $sth = $pdo->prepare("SELECT DISTINCT opdrachten.KRITISCHE_DATUM, opdrachten.PLANNINGS_DATUM, opdrachten.OPDRACHTID, onderzoekactiviteiten.A_UITVOERDER
                                FROM opdrachten
                                INNER JOIN onderzoekactiviteiten
                                ON opdrachten.OPDRACHTID=onderzoekactiviteiten.OPDRACHTID
                                WHERE PLANNINGS_DATUM = :date
                                AND A_UITVOERDER = :aid");
          $sth->execute($parameters);
          while ($row = $sth->fetch())
          {
            $cutKritDate = substr($row['KRITISCHE_DATUM'], 0, 10);
            $cutPlanDate = substr($row['PLANNINGS_DATUM'], 0, 10);
            echo "<td>Krit= " . $cutKritDate . "<br>";
            echo "Plan= " . $cutPlanDate . "<br>";
            echo "Opdracht= " . $row['OPDRACHTID'] . "</td>";
          }

        ?>
      </tr>
 </table>

我用jquery尝试了一些东西,但它根本没用。

jquery:

$('.day').click(function()
{
    $(this).nextUntil('tr.day').slideToggle(1000);
});

我有5行,不知道该做什么我已经用了很多东西,并且无法找到解决方案。

提前致谢!!

0 个答案:

没有答案