Guest User

Untitled

a guest
Dec 30th, 2016
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.33 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "vertrigo";
  5. $dbname = "db";
  6.  
  7. $conn = new mysqli($servername, $username, $password, $dbname);
  8. if ($conn->connect_error) {
  9.     die("Connection failed: " . $conn->connect_error);
  10. }
  11.  
  12. function an($hora){
  13. global $conn;
  14. $dia = date("d");
  15. $mes = date("m");
  16. $ano = date("Y");
  17. $sql = "SELECT * from argenda where hora='$hora' && dia='$dia' && mes='$mes' && ano='$ano' "; // id,hora,dia,mes,ano
  18. $result = $conn->query($sql);
  19. if($result->num_rows == 0){
  20.     return "Disponivel";
  21. } else{
  22.     return "Locado";
  23. }
  24. }
  25. ?>
  26. <table align="center" class="table" id="panel-hoje-tarde" name="panel-hoje-tarde">
  27.         <thead>
  28.           <tr>
  29.             <th>Horário</th>
  30.             <th>Status</th>
  31.             <th>Marcar</th>
  32.           </tr>
  33.         </thead>
  34.         <tbody>
  35.           <tr class="danger">
  36.             <td>13:30</td>
  37.             <td><?php echo an("13:30");?></td>
  38.             <td><button type="button" name="1330" id="1330" class="btn btn-danger" disabled="disabled">Marcar horário</button></td>
  39.  
  40.           </tr>
  41.           <tr class="success">
  42.             <td>14:00</td>
  43.             <td><?php echo an("14:00");?></td>
  44.             <td><button type="button" name="1400" id="1400" class="btn btn-success">Marcar horário</button></td>
  45.  
  46.           </tr>
  47.           <tr class="success">
  48.             <td>14:30</td>
  49.             <td><?php echo an("14:30");?></td>
  50.             <td><button type="button" name="1430" id="1430" class="btn btn-success">Marcar horário</button></td>
  51.  
  52.           </tr>
  53.           <tr class="success">
  54.             <td>15:00</td>
  55.             <td><?php echo an("15:00");?></td>
  56.             <td><button type="button" name="1500" id="1500" class="btn btn-success">Marcar horário</button></td>
  57.  
  58.           </tr>
  59.           <tr class="danger">
  60.             <td>15:30</td>
  61.             <td><?php echo an("15:30");?></td>
  62.             <td><button type="button" name="1530" id="1530" class="btn btn-danger" disabled="disabled">Marcar horário</button></td>
  63.  
  64.           </tr>
  65.           <tr class="success">
  66.             <td>16:00</td>
  67.             <td><?php echo an("16:00");?></td>
  68.             <td> <button type="button" name="1600" id="1600" class="btn btn-success">Marcar horário</button></td>
  69.  
  70.           </tr>
  71.           <tr class="danger">
  72.             <td>16:30</td>
  73.             <td><?php echo an("16:30");?></td>
  74.             <td> <button type="button" name="1630" id="1630" class="btn btn-danger" disabled="disabled">Marcar horário</button></td>
  75.  
  76.           </tr>
  77.           <tr class="danger">
  78.             <td>17:00</td>
  79.             <td><?php echo an("17:00");?></td>
  80.             <td> <button type="button" name="1700" id="1700" class="btn btn-danger" disabled="disabled">Marcar horário</button></td>
  81.  
  82.           </tr>
  83.           <tr class="success">
  84.             <td>17:30</td>
  85.             <td><?php echo an("17:30");?></td>
  86.             <td> <button type="button" name="1730" id="1730" class="btn btn-success">Marcar horário</button></td>
  87.  
  88.           </tr>
  89.           <tr class="danger">
  90.             <td>18:00</td>
  91.             <td><?php echo an("18:00");?></td>
  92.             <td>                <button type="button" name="1800" id="1800" class="btn btn-danger" disabled="disabled">Marcar horário</button></td>
  93.  
  94.           </tr>
  95.          
  96.         </tbody>
  97.       </table>
Add Comment
Please, Sign In to add comment