Advertisement
Guest User

Untitled

a guest
May 2nd, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.92 KB | None | 0 0
  1. <?php
  2.  
  3. // load DB
  4. require('Database.class.php');
  5. $database = new Database();
  6.  
  7. ?>
  8.  
  9. <!DOCTYPE html>
  10.  
  11. <html>
  12.  
  13. <head>
  14. <meta charset="UTF-8">
  15. <title>Las Vegas Summer Poker Tour</title>
  16. <style>
  17. table, th, td {
  18. border: 1px solid black;
  19. h1 { font-size: 8px; }
  20. }
  21. </style>
  22.  
  23. </head>
  24.  
  25. <body>
  26. <p> <a href="login.php" class="btn btn-danger">Login to Your Account</a></p>
  27.  
  28. <h1>2019 Las Vegas Poker Donkfest</h1>
  29.  
  30. <h1>Sort by Casino Name, Date and S-Points</h1>
  31.  
  32. <form action="index.php" method="post">
  33.  
  34. <!-- it's good to have labels for your form elements -->
  35. <label for="casinoName">Choose your casino,date and s_points</label>
  36. <br>
  37.  
  38.  
  39. <select id="casinoName" name="casinoName">
  40. <!-- set the default "all" option to 0 so if they pick all it comes through as just "0" and is easier to work with -->
  41. <option value="0">-All-</option>
  42.  
  43. <?php
  44. // get casino names
  45. $casinoNames = $database->getCasinoNames();
  46. // selected casino name if they submitted the form
  47. $selectedCasino = isset($_POST['casinoName']) ? $_POST['casinoName'] : '';
  48.  
  49. // loop through the casino names
  50. foreach ($casinoNames as $casinoName) {
  51. // here we will add selected to the <option> html tag if this is our selected casino
  52. // this way the dropdown doesn't reset every time we submit the form
  53. $selected = ($selectedCasino == $casinoName) ? 'selected' : '';
  54. echo "<option value=\"$casinoName\" $selected>$casinoName</option>";
  55. }
  56. ?>
  57. <?php
  58. // get casino dates
  59. $casinoDates = $database->getCasinoDates();
  60. // selected casino date if they submitted the form
  61. $selectedDates = isset($_POST['casinoDate']) ? $_POST['casinoDate'] : '';
  62.  
  63. // loop through the casino dates
  64. foreach ($casinoDates as $casinoDate) {
  65. // here we will add selected to the <option> html tag if this is our selected casino
  66. // this way the dropdown doesn't reset every time we submit the form
  67. $selected = ($selectedDates == $casinoDate) ? 'selected' : '';
  68.  
  69. }
  70. ?>
  71. <?php
  72. // get casino dates
  73. $s_points = $database->getS_points();
  74. // selected S-points if they submitted the form
  75. $selectedS_points = isset($_POST['s_points']) ? $_POST['s_points'] : '';
  76.  
  77. // loop through the s_points
  78. foreach ($s_points as $s_point) {
  79. // here we will add selected to the <option> html tag if this is our selected casino
  80. // this way the dropdown doesn't reset every time we submit the form
  81. $selection = ($selectedS_points == $s_point) ? 'selected' : '';
  82.  
  83. }
  84. ?>
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. </select>
  92.  
  93.  
  94.  
  95. <input type="date"
  96. name="casinoDate"
  97. value="<?php echo (isset($_POST['casinoDate']) ? $_POST['casinoDate'] : ''); ?>"
  98. min="2018-05-25"
  99. max="2018-07-31">
  100.  
  101.  
  102. <select name="s_point">
  103. <option value="0">0+</option>
  104. <option value="50">50+</option>
  105. <option value="75">75+</option>
  106. <option value="100">100+</option>
  107. value="<?php echo (isset($_POST['s_point']) ? $_POST['s_point'] : ''); ?>"
  108.  
  109.  
  110. </select>
  111.  
  112.  
  113.  
  114.  
  115. <button id="filter">Search</button>
  116. <br>
  117. <br>
  118.  
  119. <?php
  120. $tournamentId = 'id';
  121.  
  122. $sql = "INSERT into accountInfo (id)";
  123.  
  124. ?>
  125.  
  126. <form action="welcome.php" method="post">
  127. <input type="hidden" name="tournamentId" value="<?php echo $tournamentId; ?>">
  128. <button type="Save" value="Save">Save Selections?</button>
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. <div>
  138. <?php
  139.  
  140. // an example showing we know what was selected
  141. // we can do an if here because $selectedCasino will be null if nothing was submitted
  142. // or 0 if they picked -ALL-
  143. // null and 0 are both evaluated as false in an if, so this only runs if they picked an actual casino
  144. if ($selectedCasino) {
  145. echo "You chose $selectedCasino!";
  146. }
  147. ?>
  148.  
  149. <?php
  150. $servername = "localhost";
  151. $username = "root";
  152. $password = "";
  153. $dbname = "vegaspoker";
  154.  
  155. $conn = new mysqli($servername, $username, $password, $dbname);
  156.  
  157. if ($conn->connect_error) {
  158. die("Connection Failed: " . $conn->connect_error);
  159. }
  160.  
  161.  
  162.  
  163.  
  164.  
  165. // load html table
  166.  
  167.  
  168.  
  169. // load html table
  170. // I switched the and to or in the casinoDate $sql.
  171.  
  172. $sql = "SELECT * FROM tournaments WHERE true";
  173. if(isset($_POST['casinoName'])) {
  174. $sql .= " and casino = '" . $_POST['casinoName'] . "'";
  175. }
  176. if(isset($_POST['casinoDate'])) {
  177. $sql .= " and schedule BETWEEN '".$_POST['casinoDate']
  178. ." 00:00:00.00' AND '".$_POST['casinoDate']." 23:59:59.999'";
  179. }
  180. if(isset($_POST['s_point'])) {
  181. $sql .= " and s_points >= '" . $_POST['s_point'] . "'";
  182.  
  183. }
  184.  
  185.  
  186.  
  187.  
  188.  
  189. $result = $conn->query($sql);
  190. if($result == mysqli_query($conn, $sql)){
  191. if(mysqli_num_rows($result) > 0){
  192. echo "<table>";
  193. echo "<tr>";
  194. echo "<th>id</th>";
  195. echo "<th>grouping</th>";
  196. echo "<th>casino</th>";
  197. echo "<th>cost</th>";
  198. echo "<th>game</th>";
  199. echo "<th>schedule</th>";
  200. echo "<th>fee_percent</th>";
  201. echo "<th>s_points</th>";
  202. echo "<th>notes</th>";
  203. echo "</tr>";
  204.  
  205. if($result->num_rows > 0) {
  206.  
  207. while($row = $result->fetch_assoc()) {
  208. echo "<tr>";
  209. echo "<td>" . $row["id"]. "</td>";
  210. echo "<td>".$row["grouping"]."</td>";
  211. echo "<td>" . $row["casino"]. "</td>";
  212. echo "<td>". $row["cost"]. "</td>";
  213. echo "<td>". $row["game"]. "</td>";
  214. echo "<td>". $row["schedule"]."</td>";
  215. echo "<td>". $row["fee_percent"]."</td>";
  216. echo "<td>". $row["s_points"]."</td>";
  217. echo "<td>". $row["notes"]."</tr>";
  218. echo "</tr>";
  219.  
  220.  
  221. }
  222.  
  223. }
  224. }
  225. }
  226.  
  227. ?>
  228.  
  229.  
  230.  
  231. </form>
  232. </div>
  233.  
  234. </body>
  235. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement