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.
|
|
<?php // lookup
// include our database configuration
require(($category) ? "db.php3" : "cfg.php3");
// connect to the database
$connection = connect($host, $dbname); if($connection) { // set up the initial values
$multiple = 0; // begin building the query string
$query = "select * from contact"; 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"; $result = query($connection, $query); $count = numrows($result); if($count) { if($content == "mem_result") // print a summary of the result
print("Your query returned ($count) results.\n<br><br>\n"); // create the table for the results
print("<table width=520 border=0 cellpadding=1 cellspacing=0>\n"); for($row=0; $row < $count; $row++) { $data = fetch_object($result, $row); // create a category header
if($data->category != $samecategory) { if($samecategory) print("<tr><td colspan=2>  </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 . "   " . $data->phnum1); print("</td></tr>\n"); // second line
print("<tr class=$shade><td>"); print($data->address); print("</td><td align=right>"); print($data->phtyp2 . "   " . $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 . "   " . $data->phnum3); print("</td></tr>\n"); } print("</table></div>\n"); // append a "New Search" button
if($content == "mem_result") { print("<div class=offset>\n"); print("<a href=page.php3?content=$same>\n"); print("<img src=\"btn.php3?label=New+Search\" "); print("alt=\"New Search\" border=0></a>\n</div>\n"); }
// release the database query result
free_result($result); } else { print("<div class=intro>\n"); print("Sorry, your query returned an empty result.<br>\n"); print("</div>\n<div class=offset>\n<a href=page.php3?content=$same>\n"); print("<img src=\"btn.php3?label=Try+Again\" "); print("alt=\"Try Again\" border=0></a>\n</div>\n"); } // close the database connection
// close($connection);
} else { print("<div class=center><h1>Database Error<hr></h1>\n"); print("<h2>Failed to connect to database: "); print($dbname . "</h2>\n</div>\n"); } ?>
|