Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Informação da Tabela com suplemento ao JSON */
- $tabela = array(
- array(
- // NOME DA SALA PARA O CABEÇALHO DA TABELA
- 'NomeDaSala' => 'Sala 1',
- // HORARIOS EM VALORES BOOLEAN:INT (1 PARA RESERVADO E 0 PARA DISPONIVEL)
- 'Horario' => array(
- 1, // 8:00
- 1, // 9:00
- 0, // 10:00
- 1, // 11:00
- 0, // 12:00
- 1, // 13:00
- 1, // 14:00
- 1, // 15:00
- 1, // 16:00
- 0, // 17:00
- 1 // 18:00
- )
- ),
- array(
- // NOME DA SALA PARA O CABEÇALHO DA TABELA
- 'NomeDaSala' => 'Sala 2',
- // HORARIOS EM VALORES BOOLEAN:INT (1 PARA RESERVADO E 0 PARA DISPONIVEL)
- 'Horario' => array(
- 0, // 8:00
- 0, // 9:00
- 0, // 10:00
- 1, // 11:00
- 0, // 12:00
- 1, // 13:00
- 1, // 14:00
- 1, // 15:00
- 1, // 16:00
- 0, // 17:00
- 1 // 18:00
- )
- ),
- array(
- // NOME DA SALA PARA O CABEÇALHO DA TABELA
- 'NomeDaSala' => 'Sala 3',
- // HORARIOS EM VALORES BOOLEAN:INT (1 PARA RESERVADO E 0 PARA DISPONIVEL)
- 'Horario' => array(
- 0, // 8:00
- 0, // 9:00
- 0, // 10:00
- 1, // 11:00
- 0, // 12:00
- 1, // 13:00
- 1, // 14:00
- 1, // 15:00
- 1, // 16:00
- 0, // 17:00
- 1 // 18:00
- )
- ),
- );
- /* Intervalo dos Horários */
- $horarios = range(8,18);
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Tabela de Reservas</title>
- <meta charset='UTF-8'>
- <style>
- table, td, th{border: 1px solid #000 ; padding:5px;}
- </style>
- </head>
- <body>
- <!-- INICIO DA TABELA DAS RESERVAS -->
- <table>
- <thead>
- <td>Horário</td>
- <!-- INICIO DO LOOP PARA O NOME DAS SALAS -->
- <?php foreach($tabela as $sala): ?>
- <td><?php echo $sala['NomeDaSala']; ?></td>
- <?php endforeach; ?>
- <!-- FIM DO LOOP PARA O NOME DAS SALAS -->
- </thead>
- <!-- INICIO DO LOOP PARA OS HORARIOS -->
- <?php foreach($horarios as $key=>$horario): ?>
- <tr>
- <td><?php echo "{$horario}:00"; ?></td>
- <!-- INICIO DO LOOP PARA A RELACAO HORARIOS-SALAS -->
- <?php foreach($tabela as $keysala => $sala): ?>
- <td>
- <?php if($sala['Horario'][$key] == 1) echo "<a href=\"#\" onclick=\"alert('Foi escolhida a Sala: {$sala['NomeDaSala']} na Hora: {$horario}:00');\">Reservado</a>"; ?>
- <?php if($sala['Horario'][$key] == 0) echo "<a href=\"#\" onclick=\"alert('Foi escolhida a Sala: {$sala['NomeDaSala']} na Hora: {$horario}:00');\">Por Reservar</a>"; ?>
- </td>
- <?php endforeach; ?>
- <!-- FIM DO LOOP PARA A RELACAO HORARIOS-SALAS -->
- </tr>
- <?php endforeach; ?>
- <!-- FIM DO LOOP PARA OS HORARIOS -->
- </table>
- <?php foreach($tabela as $sala): ?>
- <pre>
- <?php echo json_encode($sala); ?>
- </pre>
- <?php endforeach; ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement