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.
 
 
 
 

120 lines
3.6 KiB

<?php // process the query data passed to us
header("Pragma: no-cache");
header("Content-type: text/html");
$basetarget="main";
include("html/head.std");
include("config/db.config");
include("config/db.functions." . $dbserver);
//
// connect to the database
$connection = connect($host, $dbname);
if($connection) {
// set up the initial values
$multiple = 0;
// begin building the query string
$query = "select $columns from $table";
if($category || $name || $contact) {
// append any qualifiers
$query .= " where ";
if($category) {
$query .= "category = '" . $category . "'";
$multiple++;
}
if($name) {
if($multiple) $query .= " and ";
switch($nameoption) {
case "start";
$query .= "upper(name) like upper('" . $name . "%')";
break;
case "contain";
$query .= "upper(name) like upper('%" . $name . "%')";
break;
case "end";
$query .= "upper(name) like upper('%" . $name . "')";
break;
}
$multiple++;
}
if($contact) {
if($multiple) $query .= " and ";
switch($contactoption) {
case "start";
$query .= "upper(contact) like upper('" . $contact . "%')";
break;
case "contain";
$query .= "upper(contact) like upper('%" . $contact . "%')";
break;
case "end";
$query .= "upper(contact) like upper('%" . $contact . "')";
break;
}
$multiple++;
}
}
// append an order by clause
$query .= " order by category, name, contact";
//
// print("<p><b>query:</b> " . $query . "<br>\n");
//
$result = query($connection, $query);
$total_rows = numrows($result);
if($total_rows) {
// create the table for the results
print("<table width=580 border=0 cellpadding=0 cellspacing=0>\n");
for($row=0; $row < $total_rows; $row++) {
$data = fetch_object($result, $row);
print("<tbody>\n");
// create a category header
if($data->category != $samecategory) {
if(isset($samecategory))
print("<tr><td colspan=2>&nbsp </td></tr>\n");
print("<tr class=header><th colspan=2>");
print($data->category . "</th></tr>\n");
$rowshade = 0;
$samecategory = $data->category;
}
// alternate bgcolors
$shade = (($rowshade++ & 1) ? "dark" : "light");
// first line
print("<tr class=" . $shade . "><td>");
if($data->name && $data->contact) {
print($data->name . " (" . $data->contact . ")");
} else { print($data->name . $data->contact); }
print("</td><td align=right>");
print($data->phtyp1 . "&nbsp " . $data->phnum1);
print("</td></tr>\n");
// second line
print("<tr class=" . $shade . "><td>");
print($data->address);
print("</td><td align=right>");
print($data->phtyp2 . "&nbsp " . $data->phnum2);
print("</td></tr>\n");
// third line
print("<tr class=" . $shade . "><td>");
print($data->city . ", " . $data->state . ". " . $data->zip);
if($data->zipext) { print("-" . $data->zipext); }
print("</td><td align=right>");
print($data->phtyp3 . "&nbsp " . $data->phnum3);
print("</td></tr>\n");
print("</tbody>\n");
}
print("</table>\n");
// release the database query result
free_result($result);
} else {
print("<h1 class=center>Empty Result<hr></h1>\n");
print("<h2>The following query returned an empty result:</h2>\n");
print("<p class=center>" . $query . "\n");
}
// close the database connection
close($connection);
} else {
print("<h1 class=center>Database Error<hr></h1>\n");
print("<h2 class=center>Failed to connect to database: ");
print($dbname . "</h2>\n");
}
// close up the html tags
include("html/tail.std");
?>