尝试为GYM网络创建时间表

时间:2017-05-29 08:26:22

标签: php html

我完成了学业,但现在我需要开发一个项目,我想为健身房创建一个Web应用程序,但我仍然坚持计划模块。我需要它从这样的数据库中获取信息:

+--------+------------+--------+----------+------+-----------+------------+
| ID_Act | HoraInicio | Dia    | Duracion | Sala | DNI_Prof  | Dificultad |
+--------+------------+--------+----------+------+-----------+------------+
|      1 | 09:00:00   | LUNES  | 45       | 1    | 12345678A | 2          |
|      1 | 09:00:00   | MARTES | 45       | 1    | 12345678A | 3          |
|      1 | 10:30:00   | LUNES  | 45       | 1    | 12345678A | 1          |
+--------+------------+--------+----------+------+-----------+------------+

ID_Act:活动ID

HoraInicio:开始时间

Dia:Day

Duración:持续时间

萨拉:房间

DNI_Prof:教师ID

Dificultad:等级

我一直在尝试使用for循环创建整个计划,因此我不必复制和粘贴50行。我可以使用循环创建整个计划,但是我无法在正确的单元格中打印出我需要的值。

这是我一直在尝试的代码:

    <?php session_start(); ?>
    <?php

    include("connbd.php");

    $consulta="SELECT actividades.nombre AS Actividad, ID_Act, HoraInicio, Dia, Duracion, Sala, Dificultad FROM horarios
             JOIN actividades WHERE actividades.id LIKE ID_Act;";

    $resultado=mysqli_query($conn,$consulta);

    $hora = array("09:00","09:15","09:30","09:45","10:00","10:15","10:30","10:45","11:00","11:15","11:30",
      "11:45","12:00","12:15","12:30","12:45","13:00","13:15","13:30","13:45","14:00","14:15","14:30","14:45",
      "15:00","15:15","15:30","15:45","16:00","16:15","16:30","16:45","17:00","17:15","17:30","17:45","18:00",
      "18:15","18:30","18:45","19:00","19:15","19:30","19:45","20:00","20:15","20:30","20:45","21:00");

    ?>

    <div id=contenidoHorarios class="contenidoHorarios">
    <div id=contenidoHorariosTabla class="contenidoHorariosTabla">
    <div id=contenidoHorariosTablaHoras class="contenidoHorariosTablaHoras">

    <table border="1px" id="contenidoHorariosTablaTabla" class="contenidoHorariosTablaTabla">

                  <tr>
                    <th width="5%"></th>
                    <th width="13.57%">Lunes</th>
                    <th width="13.57%">Martes</th>
                    <th width="13.57%">Miércoles</th>
                    <th width="13.57%">Jueves</th>
                    <th width="13.57%">Viernes</th>
                    <th width="13.57%">Sábado</th>
                    <th width="13.57%">Domingo</th>
                  </tr>

    <?php
      foreach ($hora as $horatupla) {
     ?>
    <tr>
      <th><?php echo $horatupla; ?></th>
      <td id="<?php
        while ($row=$resultado->fetch_assoc())
        {
          $id = $row['ID_Act'];
          $horainicio = substr($row['HoraInicio'],0,-3);
          $dia = $row['Dia'];
          $duracion = $row['Duracion'];
          $sala = $row['Sala'];
          $dificultad = $row['Dificultad'];
          $actividad = $row['Actividad'];


            if($dia=='LUNES'){echo $dia . $horatupla;} ?>" rowspan="<?php if($duracion=='15' || $duracion==''){echo '1';} if($duracion=='30'){echo '2';} if($duracion=='45'){echo '3';} ?>"

        <?php
            if ($horatupla==$horainicio)
              {
                echo $actividad;
              }
        }
        ?>>
      </td>
    </tr>

  <?php } ?>
        </table>
      </div>
    </div>
  </div>

我希望你明白我在说什么,但为了帮助你,我举一个例子说明我想做什么(没有垃圾邮件)。

http://www.go-fit.es/Horarios/Index

0 个答案:

没有答案