Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $dBUsername = "root";
- $dBPassword = "";
- $dBName = "chromebook";
- $conn = mysqli_connect($servername, $dBUsername, $dBPassword, $dBName);
- if (!$conn) {
- die("Connection Failed: ".mysqli_connect_error());
- }
- <!DOCTYPE html>
- <?php
- require "dbh.inc.php";
- ?>
- <html>
- <head>
- <title>Searching For Data</title>
- </head>
- <body>
- <?php
- echo "<h2>Search Results</h2>
- if(isset($_POST['search'])) {
- $search = $_POST['search'];
- if ($search == "") {
- echo "<p>You Didn't Submit Data! Try Again!</p><a
- href="myurlusuallyisherebutitsforaimportantthingandidontwantusersgoingtoit"</a>";
- exit;
- }
- $search = strtoupper($search);
- $search = strip_tags($search);
- $search = trim($search);
- $result = mysqli_query("SELECT * FROM chrome WHERE Teacher LIKE '%search%'");
- echo "<table class="table" border='1'>
- <tr>
- <th>Room Number</th>
- <th>Teacher</th>
- <th>Front Barcode</th>
- <th>Back Barcode</th>
- </tr>";
- while($row = mysqli_fetch_array($result)) {
- echo "<tr>";
- echo "<td>" . $row['RoomNum'] . "</td>";
- echo "<td>" . $row['Teacher'] . "</td>";
- echo "<td>" . $row['FrontId'] . "</td>";
- echo "<td>" . $row['Barcode'] . "</td>";
- echo "</tr>";
- }
- echo "</table>";
- mysqli_close($conn);
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment