Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="it">
  3.  
  4. <body>
  5.  
  6. <section style="padding: 5%; background-color: rgb(245, 245, 245)">
  7. <div class="container">
  8. <h1 style="text-align: center; font-weight: bold">Eventi In Programma</h1>
  9. <h4 style="text-align: center; padding-bottom: 5%" >prenota subito il tuo posto a tavola!</h4>
  10. <div class="card-deck">
  11. <div id="demo" class="row">
  12.  
  13. <?php
  14. include("./db/mysql_credentials.php");
  15.  
  16.  
  17. $numCards = 9;
  18. $cMax = $numCards;
  19. $cMin = 0;
  20. $cMinTmp = $cMin;
  21. $cMaxTmp = $cMax; //inutile
  22. $skip = $cMax - $numCards;
  23.  
  24.  
  25. $conn = new mysqli($mysql_server, $mysql_user, $mysql_pass, $mysql_db);
  26. if ($conn->connect_error) {
  27. die("Connection failed: " . $conn->connect_error);
  28. }
  29.  
  30. $query = "SELECT * FROM events ORDER BY date";
  31. $result = $conn->query($query);
  32.  
  33. if ($result->num_rows > 0) {
  34.  
  35.  
  36.  
  37. while($cMin!=$cMax){
  38.  
  39. //while($row = $result->fetch_assoc()){
  40.  
  41. if($row = $result->fetch_assoc()){
  42.  
  43. if($skip == $cMinTmp){
  44. echo
  45. '<div class="col-sm-4" style="padding: 2%">
  46. <div class="card">
  47. <img class="card-img-top" src='.$row["img"].' alt="Card image cap">
  48. <div class="card-body">
  49. <h5 class="card-title">'.$row["title"].'</h5>
  50. <p class="card-text">'.$row["description"].'</p>
  51. <p class="card-text">
  52. <small class="text-muted">'.$row["date"].'</small>
  53. </p>
  54. </div>
  55. </div>
  56. </div>';
  57. } else $skip--;
  58. }
  59.  
  60. $cMin++;
  61.  
  62.  
  63. };
  64.  
  65. $cMin=$cMinTmp;
  66.  
  67.  
  68. } else {
  69. echo "<h5>Non ci sono Eventi in programma</h5>";
  70. }
  71.  
  72. $conn->close();
  73. ?>
  74. </div>
  75. </div>
  76. <div id="demo" class="row" style="padding:2%;">
  77. <button type="button" id="btnPrec" onclick="" class="btn btn-outline-secondary col-sm-2 offset-sm-4"> << </button>
  78. <button type="button" id="btnNext" onclick="" class="btn btn-outline-secondary col-sm-2 "> >> </button>
  79. </div>
  80. </div>
  81. </section>
  82.  
  83.  
  84.  
  85. </body>
  86.  
  87. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement