Advertisement
Guest User

Untitled

a guest
Jun 14th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Search Engin`for entered data</title>
  4. </head>
  5. <body>
  6. <form action="search.php" method="post">
  7. <input type="text" name="results">
  8. <input type="submit" name="submit" value="search">
  9. </form>
  10. </body>
  11. </html>
  12.  
  13. <?php
  14.  
  15. $dbname = "My_database";
  16.  
  17. $dbserver = "localhost";
  18.  
  19. $user = "root";
  20.  
  21. $password = "";
  22.  
  23.  
  24. if(isset($_POST['submit']))
  25. {
  26.  
  27. $conn =new mysqli($dbserver,$user,$password,$dbname);
  28.  
  29. $valuetosearch = $_POST['results'];
  30.  
  31. $sql = "SELECT * FROM myguests WHERE CONCAT('id','fname','lname') LIKE '%".$valuetosearch."%'";
  32.  
  33. $search_result = $conn->query($sql);
  34.  
  35. }
  36.  
  37.  
  38.  
  39. while($row = $search_result->fetch_assoc())
  40. {
  41. echo "<br> id: ". $row["id"]. " - Name: ". $row["fname"]. " " . $row["lname"] . "<br>";
  42. }
  43.  
  44. $conn->close();
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement