Olive Branch MS Chamber of Commerce (circa Oct 1999)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

71 lines
1.6 KiB

  1. <?
  2. function bsearch_main($category, $wordsearch, $contactsearch, $wordoption, $contactoption)
  3. {
  4. $database_name = "olivebranch";
  5. $result = 0;
  6. $connection = pg_connect("localhost", "5432", $database_name);
  7. if($connection)
  8. {
  9. $multiple = 0;
  10. $query = "SELECT * FROM member WHERE ";
  11. if($category || $wordsearch || $contactsearch)
  12. {
  13. if($category)
  14. {
  15. $query .= "category = '" . $category . "'";
  16. $multiple = 1;
  17. }
  18. if($wordsearch)
  19. {
  20. if($multiple) $query .= " AND ";
  21. switch($wordoption)
  22. {
  23. case "start":
  24. $query .= "upper(company) LIKE upper('" . $wordsearch . "%')";
  25. break;
  26. case "contain":
  27. $query .= "upper(company) LIKE upper('%" . $wordsearch . "%')";
  28. break;
  29. case "end":
  30. $query .= "upper(company) LIKE upper('%" . $wordsearch . "')";
  31. break;
  32. }
  33. $multiple = 1;
  34. }
  35. if($contactsearch)
  36. {
  37. if($multiple) $query .= " AND ";
  38. switch($contactoption)
  39. {
  40. case "start":
  41. $query .= "upper(contact) LIKE upper('" . $contactsearch . "%')";
  42. break;
  43. case "contain":
  44. $query .= "upper(contact) LIKE upper('%" . $contactsearch . "%')";
  45. break;
  46. case "end":
  47. $query .= "upper(contact) LIKE upper('%" . $contactsearch . "')";
  48. break;
  49. }
  50. }
  51. }
  52. else $query .= "category is not null";
  53. $query .= " ORDER BY category,company,contact";
  54. $result = pg_exec($connection, $query);
  55. pg_close($connection);
  56. }
  57. return($result);
  58. }
  59. ?>