I need to inform the user if thier search has returned 0 results.
Here is a snippet of code. There are two search fields, first name and last name, they are sent to the php page via a POST form.
BTW: The search page is available online at http://www.ellisandrews.org/search.html
If the enter a full name (or even partial name) that returns nothing, I would like to inform them, instead of building an empty table, which is what it does now.
$form_first = $HTTP_POST_VARS['first'];
$form_last = $HTTP_POST_VARS['last'];
$form_city = $HTTP_POST_VARS['city'];
$form_state = $HTTP_POST_VARS['state'];
/ Start query statement /
$query = ("SELECT * FROM Info WHERE");
// if the first name has value
//if ($HTTP_POST_VARS['first']){
$query .= " First LIKE '%$form_first%'";
//}
// if the last name has value
if ($HTTP_POST_VARS['last']){
$query .= " AND Last LIKE '%$form_last%'";
}
// if city has a value
if ($HTTP_POST_VARS['city']){
$query .= " AND City = '$form_city'";
}
// if state has a value
if ($HTTP_POST_VARS['state']){
$query .= " AND State = '$form_state'";
}
/ End query statement /
$data = mysql_query($query);
echo "<table name='results' border='1' cellpadding='0'>";
echo "<H1>Search Results:</H1>";
echo "<tr>";
echo "<td><b>First</td>";
echo "<td><b>Last</td>";
echo "<td><b>Street</td>";
echo "<td><b>City</td>";
echo "<td><b>State</td>";
echo "<td><b>Zip</td>";
echo "<td><b>Email<td></tr>";
while($d = mysql_fetch_array($data)) {
$vfirst = $d[First];
$vlast = $d[Last];
$vstreet1 = $d[Street1];
$vcity = $d[City];
$vstate = $d[State];
$vzip = $d[Zip];
$vemail = $d[Email];
echo "<tr><td>$vfirst</td>";
echo "<td>$vlast</td>";
echo "<td>$vstreet1</td>";
echo "<td>$vcity</td>";
echo "<td>$vstate</td>";
echo "<td>$vzip</td>";
echo "<td><a href='mailto:$vemail'>$vemail</a></td></tr>";
}
?>