Advertisement
johnneijzen

Search_form.PHP

Oct 5th, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.87 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.   <head>
  4.     <!-- Required meta tags -->
  5.     <meta charset="utf-8">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7.  
  8.     <!-- Font Awesome -->
  9.     <link rel="stylesheet" href="font-awesome/css/font-awesome.css">
  10.     <!-- Bootstrap CSS -->
  11.     <link rel="stylesheet" href="css/bootstrap.min.css">
  12.     <link rel="stylesheet" href="w3.css">
  13.   </head>
  14.  
  15.   <body>
  16.     <table class="table">
  17.  
  18.     <?php
  19.     $servername = "localhost";
  20.     $username   = "root";
  21.     $password   = "";
  22.     $dbname     = "library";
  23.    
  24.     // Create connection
  25.     $conn = mysqli_connect($servername, $username, $password, $dbname);
  26.     // Check connection
  27.     if (!$conn) {
  28.         die("Connection failed: " . mysqli_connect_error());
  29.     }
  30.    
  31.     $search_value = $_POST['search'];
  32.     $sql          = "SELECT * FROM books WHERE Title LIKE '%$search_value%'";
  33.     $result       = mysqli_query($conn, $sql);
  34.    
  35.     if (mysqli_num_rows($result) > 0) {
  36.         echo "<thead><tr><th>ISBN</th><th>Publisher_ID</th><th>Title</th><th>Author</th><th>Rack No</th><th>No_of_books</th><th>Date of Purchase</th><th>No Available</th><th>Category ID</th></tr></thead>";
  37.         // output data of each row
  38.         while ($row = mysqli_fetch_assoc($result)) {
  39.             echo "<tbody><tr><td>" . $row["ISBN"] . "</td><td>" . $row["Publisher_ID"] . "</td><td><button type=\"button\" class=\"btn btn-secondary\" data-toggle=\"modal\" data-target=\"#Model\">" . $row["Title"] . " </button></td><td>" . $row["Author"] . "</td><td>" . $row["Rack_No"] . "</td><td>" . $row["No_of_books"] . "</td><td>" . $row["Date_of_Purchase"] . "</td><td>" . $row["No_Available"] . "</td><td>" . $row["Category_ID"] . "</td></tr></tbody>";
  40.         }
  41.         echo "</table>";
  42.     } else {
  43.         echo "0 results";
  44.     }
  45.     mysqli_close($conn);
  46. ?>
  47.  
  48.     <!-- Modal -->
  49.     <div class="modal fade" id="Model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
  50.       <div class="modal-dialog" role="document">
  51.         <div class="modal-content">
  52.           <div class="modal-header">
  53.             <h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
  54.             <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  55.               <span aria-hidden="true">&times;</span>
  56.             </button>
  57.           </div>
  58.           <div class="modal-body">
  59.             <form class="w3-container" action="/action_page.php">
  60.                 <div class="w3-section">
  61.                     <label><b>ISBN</b></label>
  62.                     <input class="w3-input w3-border w3-margin-bottom" type="text1" placeholder="Enter ISBN" name="usrname" required>
  63.                     <label><b>Title</b></label>
  64.                     <input class="w3-input w3-border w3-margin-bottom" type="text1" placeholder="Enter Book Title" name="usrname" required>
  65.                     <label><b>Author</b></label>
  66.                     <input class="w3-input w3-border w3-margin-bottom" type="text1" placeholder="Enter Book Author" name="usrname" required>
  67.                     <label><b>Publisher ID</b></label>
  68.                     <input class="w3-input w3-border w3-margin-bottom" type="text1" placeholder="Enter Publisher ID" name="usrname" required>
  69.                     <label><b>Rack No.</b></label>
  70.                     <input class="w3-input w3-border w3-margin-bottom" type="text1" placeholder="Enter Rack No." name="usrname" required>
  71.                     <label><b>No. Of Books</b></label>
  72.                     <input class="w3-input w3-border w3-margin-bottom" type="text1" placeholder="Enter No. Of Books" name="usrname" required>
  73.                     <button class="w3-button w3-block w3-green w3-section w3-padding" type="submit">Update</button>
  74.                    
  75.                 </div>
  76.             </form>
  77.             <form class="w3-container" action="/action_page.php">
  78.                 <div class="w3-section">
  79.                     <button class="w3-button w3-block w3-green w3-section w3-padding" type="submit">Delete</button>
  80.                 </div>
  81.              </form>
  82.           </div>
  83.           <div class="modal-footer">
  84.             <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  85.           </div>
  86.         </div>
  87.       </div>
  88.     </div>
  89.     <!-- Optional JavaScript -->
  90.     <!-- jQuery first, then Popper.js, then Bootstrap JS -->
  91.     <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  92.     <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
  93.     <script src="js/bootstrap.min.js"></script>
  94.   </body>
  95. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement