search.php
Code: Select all
<html>
<body>
<form action="dir_results.php" method="post">
Choose to Search by
<br />Catagory:
<select name="category">
<option value="%">All</option>
<option>Accountants</option>
<option>Attorneys</option>
<option>Financial Planners</option>
<option>Insurance Agents</option>
<option>Trust Officers</option>
<option>Associates</option>
</select>
<br />Name:
<input type="text" name="name" maxlength=60 size=30 />
<br />
<input type="submit" value="Search" />
</form>
</body>
</html>dir_results.php
Code: Select all
<html>
<body>
<?php
// Connecting
include("includes/dblogin.php");
mysql_connect($host,$user,$pass) or die("Couldn't connect to database.");
mysql_select_db($db) or die("Couldn't select database");
$table = directory_members;
$query = "SELECT * FROM $table WHERE (name IS NOT NULL AND name LIKE '".$name."') or (category LIKE '".$category."') ORDER BY category, name ASC"; // DESC for decending
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
while ($field = mysql_fetch_array($result)) {
$type = $fieldї"category"];
$name = $fieldї"name"];
$portrait = $fieldї"portrait"];
$firm = $fieldї"firm"];
$position = $fieldї"position"];
$street1 = $fieldї"street1"];
if ($fieldї"street2"] = "") {
$street2 = "";
} else {
$street2 = "<br /> ".$fieldї"street2"];
}
$city = $fieldї"city"];
$state = $fieldї"state"];
$zip = $fieldї"zip"];
$email = $fieldї"email"];
$phone = $fieldї"phone"];
$fax = $fieldї"fax"];
$website = $fieldї"website"];
$output = <<<EOF
<table width="500px" height="300px" bgcolor="">
<tr><td>
<table width="40%" height="100%" bgcolor="" ALIGN="left"><TR>
<td><br /><img src=$portrait width="200px" height="200px" /></td>
</TR></table>
<table width="58%" height="100%" bgcolor="" ALIGN="right"><TR><td>
<b>$type</b>
<br />$name
<br />$firm
<br />$street1
$street2
<br />$city, $state $zip
<br /> Phone: $phone
<br /> Fax: $fax
<br /> Email: <a href="mailto: $email">$email</a>
<br /> Website: <a href="$website" >$website</a>
</td></TR></table>
</td></tr>
</table>
EOF;
echo $output;
}
echo "<p>Number of results found: ".$num_results."</p>";
?>
</body>
</html>