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.
64 lines
2.7 KiB
64 lines
2.7 KiB
<?php // contact search form
|
|
|
|
// provide access to external db config variables
|
|
require("cfg.php3");
|
|
|
|
// connect to the db and build the category list
|
|
$link = connect($host, $dbname);
|
|
if($link) {
|
|
$query = "select distinct category from contact";
|
|
$result = query($link, $query);
|
|
$count = numrows($result);
|
|
// if we return a list of categories,
|
|
// build our form for the data query
|
|
if($count) {
|
|
print("<br>\n<br>\n<form method=\"post\" action=\"page.php3?");
|
|
print("content=mem_result\">\n<table border=0>\n");
|
|
print("<tr>\n <td class=label>Category:</td>\n");
|
|
print(" <td class=data>\n <select name=\"category\">\n");
|
|
print(" <option value=\"\">--- All Categories ---\n");
|
|
for($row = 0; $row < $count; $row++) {
|
|
$data = fetch_object($result, $row);
|
|
print(" <option value=\"$data->category\">");
|
|
print("$data->category\n");
|
|
}
|
|
free_result($result);
|
|
print(" </select></td></tr>\n");
|
|
print(" <input type=\"hidden\" name=\"same\" value=\"$content\">\n");
|
|
|
|
print("<tr>\n <td class=label>Company Name:</td>\n <td class=data>");
|
|
print("<input type=\"text\" name=\"name\" size=28 maxlength=28></td>");
|
|
print("</tr>\n<tr>\n");
|
|
// cover for missing items
|
|
// print("<input type=\"hidden\" name=\"nameoption\" value=\"contain\">\n");
|
|
// print("<input type=\"hidden\" name=\"contactoption\" value=\"contain\">\n");
|
|
print("<td></td>\n");
|
|
print("<td class=center>\n <input type=");
|
|
print("\"radio\" name=\"nameoption\" value=\"start\">starts with\n ");
|
|
print("<input type=\"radio\" checked name=\"nameoption\" value=");
|
|
print("\"contain\">contains\n <input type=\"radio\" name=\"nameoption\"");
|
|
print(" value=\"end\">ends with\n </td></tr>\n<tr>\n");
|
|
print(" <td class=label>");
|
|
print("Contact Name:</td><td class=data>\n <input type=\"text\" ");
|
|
print("name=\"contact\" size=28 maxlength=28></td></tr>\n");
|
|
print("<tr>\n <td>");
|
|
print("</td>\n <td class=center>\n");
|
|
print("<input type=\"radio\" name=\"");
|
|
print("contactoption\" value=\"start\">starts with\n <input type=");
|
|
print("\"radio\" checked name=\"contactoption\" value=\"contain\">");
|
|
print("contains\n <input type=\"radio\" name=\"contactoption\" value=");
|
|
print("\"end\">ends with\n </td></tr>\n<tr>\n");
|
|
print(" <td colspan=2>   ");
|
|
print("</td></tr>\n<tr>\n <td colspan=2 align=center><input type=");
|
|
print("\"submit\"></td></tr>\n</table>");
|
|
|
|
} else {
|
|
print("<div class=center>\n<h2>Empty Result:</h2>\n");
|
|
print("<h2>The following query returned an empty ");
|
|
print("result:</h2><p>$query");
|
|
}
|
|
} else {
|
|
print("<div class=center>\n<h2>Database Error</h2>\n");
|
|
print("<h2>Failed to connect to database: $dbname</h2>\n");
|
|
}
|
|
?>
|