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.
 
 
 
 

241 lines
7.4 KiB

<html>
<head>
<title>Olive Branch, MS</title>
</head>
<link rel=stylesheet href=/styles/basic.css type=text/css>
<body>
<?
// $linesperpage = 10;
$database_name = "olivebranch";
//print("<b>Search criteria:</b><br>\n");
print("<form method=\"post\" action=\"bsearchresult.php3\">");
$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";
// print("<p><b>query:</b> " . $query . "<p>\n");
$result = pg_exec($connection, $query);
if($result)
{
$total_rows = pg_numrows($result);
if($linesperpage <= 0) $linesperpage = $total_rows;
$total_pages = (($total_rows - 1) / $linesperpage) + 1;
settype($total_pages, "integer");
switch($bsact)
{
case " < ":
$begin -= $linesperpage;
if($begin < 0) { $begin = 0; $page = 1; }
else $page--;
break;
case " > ":
$begin += $linesperpage;
if($begin > ($total_rows - $linesperpage))
{
$begin = $total_rows - $linesperpage;
$page = $total_pages;
}
else $page++;
break;
case ">>":
$begin = $total_rows - $linesperpage;
$page = $total_pages;
break;
default:
$begin = 0;
$page = 1;
break;
}
$last_row = $begin + $linesperpage;
if($last_row > $total_rows) $last_row = $total_rows;
print("<input type=\"hidden\" name=\"linesperpage\" value=\"" . $linesperpage . "\">\n");
print("<input type=\"hidden\" name=\"begin\" value=\"" . $begin . "\">\n");
print("<input type=\"hidden\" name=\"page\" value=\"" . $page . "\">\n");
print("<input type=\"hidden\" name=\"category\" value=\"" . $category . "\">\n");
print("<input type=\"hidden\" name=\"wordsearch\" value=\"" . $wordsearch . "\">\n");
print("<input type=\"hidden\" name=\"wordoption\" value=\"" . $wordoption . "\">\n");
print("<input type=\"hidden\" name=\"contactsearch\" value=\"" . $contactsearch . "\">\n");
print("<input type=\"hidden\" name=\"contactoption\" value=\"" . $contactoption . "\">\n");
// $url_arg = "&begin=$begin&page=$page&category=";
// $url_args .= urlencode($category);
// $url_args .= "&wordsearch=$wordsearch&wordoption=$wordoption&contactsearch=$contactsearch&contactoption=$contactoption";
print("<table border=0 width=\"450\" cellspacing=0 cellpadding=0><tr>");
if($total_rows > $linesperpage && $begin > 0)
{
print("<td align=left width=\"100\"><input type=\"submit\" name=\"bsact\" value=\"<<\">\n");
print("<input type=\"submit\" name=\"bsact\" value=\" < \"></td>\n");
// print("<td align=left width=\"100\"><a href=\"bsearchresult.php3?bsact=first" . $url_args . "\">First</a>\n");
// print("<a href=\"bsearchresult.php3?bsact=prev" . $url_args . "\">Prev</a></td>\n");
}
else print("<td width=\"100\"></td>\n");
print("<th align=center><b>Page $page of $total_pages</b></th>\n");
if($total_rows > $linesperpage && $begin != ($total_rows - $linesperpage))
{
print("<td align=right width=\"100\"><input type=\"submit\" name=\"bsact\" value=\" > \">\n");
print("<input type=\"submit\" name=\"bsact\" value=\">>\"></td>\n");
// print("<td align=right width=\"100\"><a href=\"bsearchresult.php3?bsact=next" . $url_args . "\">Next</a>\n");
// print("<a href=\"bsearchresult.php3?bsact=last" . $url_args . "\">Last</a></td>\n");
}
else print("<th width=\"100\"></th>\n");
print("</tr></table><br>\n");
print("<table border=0 width=450 cellspacing=0 cellpadding=0>\n");
print("<tr><td colspan=3></td></tr>\n");
for($row = $begin, $row_style=0; $row < $last_row; $row++, $row_style++)
{
$row_data = pg_fetch_row($result, $row);
if($row_data[0] != $previous_category)
{
if(isset($previous_category))
print("<tr><td colspan=3>&nbsp</td></tr>\n");
$previous_category = $row_data[0];
print("<tr class=header><th align=center colspan=3>$row_data[0]</th></tr>\n");
// print("<tr><td colspan=3></td></tr>\n");
$row_style = 0;
}
// else print("<tr><td colspan=3><hr></td></tr>\n");
if($row_data[1])
{
if($row_style & 1) print("<tr class=darkrow>");
else print("<tr class=lightrow>");
print("<td align=left colspan=2>");
print($row_data[1]);
print("</td><td align=right colspan=1>");
if($row_data[2]) print($row_data[2]);
}
else
{
if($row_style & 1) print("<tr class=darkrow>");
else print("<tr class=lightrow>");
print("<td align=left colspan=3>");
if($row_data[2]) print($row_data[2]);
}
print("</td></tr>\n");
if($row_style & 1) print("<tr class=darkrow>");
else print("<tr class=lightrow>");
print("<td align=left colspan=2 width=\"60%\">");
if($row_data[3]) print($row_data[3]);
print("</td><td align=right colspan=1 width=\"40%\">");
if($row_data[4]) print("$row_data[4], ");
if($row_data[5]) print("$row_data[5]");
if($row_data[6]) print(" $row_data[6]");
if($row_data[7]) print("-$row_data[7]");
print("</td></tr>\n");
$num_phones = (pg_numfields($result) - 8) / 2;
for($phone = 0, $field = 8; $phone < $num_phones; $phone++, $field += 2)
{
if(($phone % 3) == 0)
{
if($row_style & 1) print("<tr class=darkrow>");
else print("<tr class=lightrow>");
}
print("<td");
switch($phone % 3)
{
case 0:
print(" align=left");
break;
case 1:
if(($phone+1) == $num_phones)
print(" align=right colspan=2");
else print(" align=middle");
break;
case 2:
print(" align=right");
break;
}
print(">");
if($row_data[$field] && $row_data[$field+1])
print($row_data[$field] . " : " . $row_data[$field+1]);
else print("&nbsp");
print("</td>");
if(($phone % 3) == 2) print("</tr>\n");
}
}
print("</table>\n");
pg_freeresult($result);
}
else print("Search criteria yield no results.<br>\n");
pg_close($connection);
print("</form>\n");
}
?>
</body>
</html>