Guest User

youtube.com/chiefsaffinity <-- sub4sub

a guest
Feb 17th, 2016
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4. <title>Wild Scot Trust Search Results</title>
  5.  
  6. <link rel="stylesheet" type="text/css" href="Wild Scot Trust Style.css">
  7. </head>
  8.  
  9. <body>
  10. <h1>Wild Scot Trust Search Results</h1>
  11.  
  12. <p> <img src="trust_logo.jpg" alt="Wild Scot Trust Logo" align="middle" width="150" height="150"> </p>
  13.  
  14. <br>
  15. <br>
  16.  
  17. <?php
  18.  
  19. $servername="localhost";
  20. $username="root";
  21. $password="";
  22. $database="wildscottrust";
  23. $link = mysql_connect($servername,$username,$password);
  24.  
  25. mysql_select_db($database,$link) or die("Connection with database failed!");
  26.  
  27. $searchCategory=$_GET['Category'];
  28. $searchName=$_GET['Animal'];
  29.  
  30. If ($searchName == "" && $searchCategory == "") { //Check that a search criteria has been entered
  31. echo "You must enter a search criteria";}
  32. else {
  33.  
  34. If ($searchName !== "") {
  35. $queryString=("SELECT AnimalName,Category,BestPlaceToSee FROM animal WHERE AnimalName = '$searchName'");}
  36. else {
  37. $queryString=("SELECT AnimalName,Category,BestPlaceToSee FROM animal WHERE Category = '$searchCategory'");}
  38.  
  39. $qry_result = mysql_query($queryString) or die(mysql_error());
  40.  
  41. if (mysql_num_rows($qry_result)==0){
  42. echo "No animal with that name in the database";}
  43. else{
  44. echo '<table border="1"><tr><th>Animal Name</th><th>Category</th><th>Best Place To See</th></tr>';
  45. while($row = mysql_fetch_array($qry_result)) { //Repeat for all rows returned
  46. echo '<tr><td>'.$row['AnimalName'].'</td><td>'.$row['Category'].'</td><td>'.$row['BestPlaceToSee'].'</td></tr>';}
  47. }
  48. }
  49.  
  50. ?>
  51.  
  52.  
  53. <br>
  54. <p><a href="Wild Scot Trust.html">Return to Home Page</a></p>
  55.  
  56. </body>
  57.  
  58. </html>
Add Comment
Please, Sign In to add comment