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.
71 lines
1.6 KiB
71 lines
1.6 KiB
<?
|
|
function bsearch_main($category, $wordsearch, $contactsearch, $wordoption, $contactoption)
|
|
{
|
|
$database_name = "olivebranch";
|
|
$result = 0;
|
|
|
|
$connection = pg_connect("localhost", "5432", $database_name);
|
|
if($connection)
|
|
{
|
|
$multiple = 0;
|
|
$query = "SELECT * FROM member WHERE ";
|
|
|
|
if($category || $wordsearch || $contactsearch)
|
|
{
|
|
if($category)
|
|
{
|
|
$query .= "category = '" . $category . "'";
|
|
|
|
$multiple = 1;
|
|
}
|
|
|
|
if($wordsearch)
|
|
{
|
|
if($multiple) $query .= " AND ";
|
|
|
|
switch($wordoption)
|
|
{
|
|
case "start":
|
|
$query .= "upper(company) LIKE upper('" . $wordsearch . "%')";
|
|
break;
|
|
case "contain":
|
|
$query .= "upper(company) LIKE upper('%" . $wordsearch . "%')";
|
|
break;
|
|
case "end":
|
|
$query .= "upper(company) LIKE upper('%" . $wordsearch . "')";
|
|
break;
|
|
}
|
|
|
|
$multiple = 1;
|
|
}
|
|
|
|
if($contactsearch)
|
|
{
|
|
if($multiple) $query .= " AND ";
|
|
|
|
switch($contactoption)
|
|
{
|
|
case "start":
|
|
$query .= "upper(contact) LIKE upper('" . $contactsearch . "%')";
|
|
break;
|
|
case "contain":
|
|
$query .= "upper(contact) LIKE upper('%" . $contactsearch . "%')";
|
|
break;
|
|
case "end":
|
|
$query .= "upper(contact) LIKE upper('%" . $contactsearch . "')";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else $query .= "category is not null";
|
|
|
|
$query .= " ORDER BY category,company,contact";
|
|
|
|
$result = pg_exec($connection, $query);
|
|
pg_close($connection);
|
|
}
|
|
|
|
return($result);
|
|
}
|
|
?>
|
|
|