Guest User

Untitled

a guest
Feb 8th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $dBUsername = "root";
  4. $dBPassword = "";
  5. $dBName = "chromebook";
  6.  
  7. $conn = mysqli_connect($servername, $dBUsername, $dBPassword, $dBName);
  8.  
  9. if (!$conn) {
  10. die("Connection Failed: ".mysqli_connect_error());
  11. }
  12.  
  13. <!DOCTYPE html>
  14. <?php
  15. require "dbh.inc.php";
  16. ?>
  17. <html>
  18. <head>
  19. <title>Searching For Data</title>
  20. </head>
  21. <body>
  22. <?php
  23.  
  24. echo "<h2>Search Results</h2>
  25. if(isset($_POST['search'])) {
  26. $search = $_POST['search'];
  27.  
  28. if ($search == "") {
  29. echo "<p>You Didn't Submit Data! Try Again!</p><a
  30. href="myurlusuallyisherebutitsforaimportantthingandidontwantusersgoingtoit"</a>";
  31. exit;
  32. }
  33.  
  34. $search = strtoupper($search);
  35. $search = strip_tags($search);
  36. $search = trim($search);
  37.  
  38. $result = mysqli_query("SELECT * FROM chrome WHERE Teacher LIKE '%search%'");
  39.  
  40. echo "<table class="table" border='1'>
  41. <tr>
  42. <th>Room Number</th>
  43. <th>Teacher</th>
  44. <th>Front Barcode</th>
  45. <th>Back Barcode</th>
  46. </tr>";
  47.  
  48. while($row = mysqli_fetch_array($result)) {
  49. echo "<tr>";
  50. echo "<td>" . $row['RoomNum'] . "</td>";
  51. echo "<td>" . $row['Teacher'] . "</td>";
  52. echo "<td>" . $row['FrontId'] . "</td>";
  53. echo "<td>" . $row['Barcode'] . "</td>";
  54. echo "</tr>";
  55. }
  56. echo "</table>";
  57.  
  58. mysqli_close($conn);
  59. ?>
  60. </body>
  61. </html>
Add Comment
Please, Sign In to add comment