Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <html>
  2. <h2>Search</h2>
  3. <form name="search" method="post" action="<?=$PHP_SELF?>">
  4. Search for: <input type="text" name="find" /> in <Select NAME="field">
  5. <Select NAME="field">
  6. <Option VALUE="fname">First Name</option>
  7. <Option VALUE="lname">Last Name</option>
  8. <Option VALUE="info">Profile</option>
  9. </Select>
  10. <input type="hidden" name="searching" value="yes" />
  11. <input type="submit" name="search" value="Search" />
  12. </form>
  13.  
  14. <?php
  15. // put your code here
  16.  
  17. $servername = "localhost";
  18. $username = "root";
  19. $password = "";
  20. $dbname = "olympics";
  21.  
  22. // Create connection
  23. $conn = mysqli_connect($servername, $username, $password, $dbname);
  24. // Check connection
  25. if (!$conn) {
  26. die("Connection failed: " . mysqli_connect_error());
  27. }
  28.  
  29. $sql = "SELECT * FROM tasters WHERE upper($field) LIKE'%$find%'");
  30. $result = mysqli_query($conn, $sql);
  31.  
  32. if (mysqli_num_rows($result) > 0) {
  33. // output data of each row
  34. while($row = mysqli_fetch_assoc($result)) {
  35.  
  36.  
  37. echo '<a href="session-details.php?id=' . $row["Number"] . '">' . $row["Taster"] . ' ' . $row["Venue"] . '</a><br>';
  38.  
  39.  
  40. }
  41. } else {
  42. echo "0 results";
  43. }
  44.  
  45. mysqli_close($conn);
  46.  
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement