Hi all.

I am working on a helper script that runs on a wamp server at my office - firstly I am no php or mysql expert and I appologize for the sloppy coding below.

I have created this search script and it works well enough but I would like to include a "Nothing Found" echo.

everything i have tried put "Nothing Found" at the end of the result even if there are results and I am struggling to get it to work.

this is the working code snippet -

<?php
// get search term from search page
$term = $_POST['term'];
// connect to database
mysql_connect ("localhost", "username","password") or die (mysql_error());
mysql_select_db ("database");
// check stores table for results
$sql = mysql_query("select * from stores where store_name like '%$term%' OR store_number like '%$term%' OR store_address like '%$term%'");
// if search term is empty
if ($term == '') {
echo "<meta http-equiv=\"refresh\" content=\"4; url=imain.php\">";
echo "<font face=\"Verdana\" size=\"2\"><strong>No Search Term Entered</strong><br><br>";
echo "Returning to main page...";
echo "</font>";
} else {
// if search term is empty 2 - return empty if tip is returned from search page
if ($term == 'Quick Search...') {
echo "<meta http-equiv=\"refresh\" content=\"4; url=imain.php\">";
echo "<font face=\"Verdana\" size=\"2\"><strong>No Search Term Entered</strong><br><br>";
echo "Returning to main page...";
echo "</font>";
} else {
// return search results for stores
echo "<font face=\"Verdana\" size=\"2\">The following entries were found for your search term "<strong>$term</strong>"<hr></font><bloc...
while ($row = mysql_fetch_array($sql)){
// strip white spaces for link
$link = $row["store_name"];
$link = str_replace(' ', '', $link);
$link = strtolower($link);
echo "<font face=\"Verdana\" size=\"2\"><a href=\"stores/zone" .$row['store_zone'];
echo "/region" .$row['store_region'];
echo "/" .$link;
echo "\"><strong><u>" .$row['store_name'];
echo "</u></strong><br>";
echo "Store Number - " .$row['store_number'];
echo "<br>";
echo "Tel - " .$row['store_tel'];
echo "<br>";
echo "Zone <strong>" .$row['store_zone'];
echo "</strong> Region <strong>" .$row['store_region'];
echo "</strong></a></font><br><br>";
}
}
// check area managers table for results
$sql = mysql_query("select * from ram_manager where ram_name like '%$term%'");
// return search results for area managers
while ($row = mysql_fetch_array($sql)){
echo "<font face=\"Verdana\" size=\"2\"><a href=\"stores/zone" .$row['ram_zone'];
echo "/region" .$row['ram_region'];
echo "\"><strong><u>" .$row['ram_name'];
echo "</u></strong><br>";
echo "Tel - " .$row['ram_tel'];
echo "<br>";
echo "Zone <strong>" .$row['ram_zone'];
echo "</strong> Region <strong>" .$row['ram_region'];
echo "</strong><br>Status = <font color=\"" .$row['ram_statuscolor'];
echo "\">" .$row['ram_status'];
echo "</font>";
echo "</a></font><br><br>";
}
// check zone managers table for results
$sql = mysql_query("select * from zone_manager where zom_name like '%$term%'");
// return results for zone managers
while ($row = mysql_fetch_array($sql)){
echo "<font face=\"Verdana\" size=\"2\"><a href=\"stores/zone" .$row['zom_zone'];
echo "\"><strong><u>" .$row['zom_name'];
echo "</u></strong><br>";
echo "Tel - " .$row['zom_tel'];
echo "<br>";
echo "Zone <strong>" .$row['zom_zone'];
echo "</strong><br>Status = <font color=\&
Yahoo gtrimmed the end of my code - here is the last few lines from the trimmed line

echo " Status = " .$row['zom_status'];
echo " ";
echo " ";
}
}
?

Thanks

Regards
Dave K