Advertisement
Guest User

Untitled

a guest
May 29th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <HTML>
  2. <?php
  3.  
  4. $maxprice = $_REQUEST["maxprice"];
  5. $minprice = $_REQUEST["minprice"];
  6. $beds = $_REQUEST["beds"]
  7. //setup the variables for accessing the database
  8. $server = "ephesus";
  9. $username = "scm9hab";
  10. $password = "koleft";
  11. $database = "db10x9hab";
  12.  
  13. //connect to the database server
  14. $connection = mysql_connect($server, $username, $password);
  15.  
  16. //specify the database that we want to access
  17. mysql_select_db($database);
  18.  
  19.  
  20.  
  21. //build a database query
  22. $query = "SELECT * FROM Properties WHERE Beds >= $beds AND Price <= $maxprice AND Price >= $minprice";
  23.  
  24. //execute the query and get the results back from the database
  25. $results = mysql_query($query);
  26. ?>
  27. <TABLE border=1>
  28. <TR><TD>PropertyID</TD><TD>Address</TD><TD>Price</TD><TD>Image</TD></TR>
  29.  
  30. <?php
  31. //loop through the results in turn (assigning each to $row)
  32. while ($row = mysql_fetch_row($results))
  33. {
  34. //get the individual fields from this row
  35. $id = $row[0];
  36. $address= $row[1];
  37. $price = $row[2];
  38. $image = $row[3];
  39.  
  40. //print the field data to the browser
  41. print "<TR><TD>$id</TD><TD>$address</TD><TD>$price</TD><TD><IMG SRC='images/properties/$image' height='30' width='30'/></TD><TR>";
  42. }
  43.  
  44. mysql_close($connection);
  45.  
  46. ?>
  47. </TABLE>
  48. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement