This is my first PHP/MYSQL attempt.
All is going well I have a database with sales reps and zip codes they rep.
If you do a search for the zip code in the DB it works perfect.
What I want to do though is if the user searches for a Zip not in my database I want to echo a message, for example no results found or link them to a page.
If anyone can help me setup a if/else for no results it would be appreciated. Tried several things, but no luck.
Here is the code that works for the search if Zip exists:
[php]<?php
mysql_connect (“localhost”, “peterson_galiant”,“p3t3rs0n”) or die (mysql_error());
mysql_select_db (“peterson_zipcode”);
$term = $_POST[‘term’];
$sql = mysql_query(“select * from reps_zip where zip like ‘%$term%’”);
while ($row = mysql_fetch_array($sql)){
echo ‘’;
echo ‘
’.$row[‘name’];
echo ’
Contact Info’;
echo ‘
’;
}
?>[/php]