Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. if (empty($_GET['avgrating']) && empty($_GET['location'])) //both field is empty will only filter by contract type
  2. {
  3. $sql="SELECT email,contract_type,phonenumber,postalcode FROM contractors WHERE contract_type='" . $_GET['contract_type'] . "'";
  4. echo "no opt ";
  5. }
  6. elseif (empty($_GET['location'])) // location field is empty and will ony filter by contract and rating
  7. {
  8. $sql="SELECT email,contract_type,phonenumber,postalcode FROM contractors WHERE contract_type='" . $_GET['contract_type'] . "' AND avgrating >='" . $_GET['avgrating'] . "'";
  9. echo "avg ";
  10. }
  11. elseif (empty($_GET['avgrating'])) //avgrating field is empty
  12. {
  13. $sql="SELECT email,contract_type,phonenumber,postalcode FROM contractors WHERE contract_type='" . $_GET['contract_type'] . "' AND location='" . $_GET['location'] . "'";
  14. echo "location ";
  15. }
  16. else //all field is provided
  17. {
  18. $sql="SELECT email,contract_type,phonenumber,postalcode FROM contractors WHERE contract_type='" . $_GET['contract_type'] . "' AND avgrating >='" . $_GET['avgrating'] . "' AND location='" . $_GET['location'] . "'";
  19. echo "avg + location ";
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement