I'm working on this project where they can search a list of names and they can put in a death year that automatically searches for + and - 5 years.
mysql_connect ("localhost", "root","root") or die (mysql_error());
mysql_select_db ("FHSNL");
$surname = $_POST['surname'];
$given = $_POST['given'];
$maiden = $_POST['maiden'];
$deathbefore = $_POST['death'] - 5;
$deathafter = $_POST['death'] + 5;
$age = $_POST['age'];
$birth = $_POST['birth'];
$birthplace = $_POST['birthplace'];
$deathplace = $_POST['deathplace'];
$erected = $_POST['erected'];
$region = $_POST['region'];
if(isset($_POST['submit'])){
$sql = mysql_query("SELECT * FROM `HEADSTONES` WHERE `SURNAME` LIKE '%$surname%' AND `GIVEN` LIKE '%$given%' AND `MAIDEN` LIKE '%$maiden%' AND `AGE` LIKE '%$age%' AND `D_OF_BIRTH` LIKE '%$birth%' AND `PLACE_OF_DEATH` LIKE '%$deathplace%' AND `ERECTED_BY` LIKE '%$erected%' AND `PLACE_OF_BIRTH` LIKE '%$birthplace%' AND `Expr3` LIKE '%$region%' AND `YEAR_OF_DEATH` BETWEEN '$deathbefore' AND '$deathafter'");
I know the problem is that deathbefore and deathafter automatically go to -5 or +5 if no one enters a search term no results show but how do i fix this so all the results show if no search term is entered in that input box? Its probably a simple solution but my brain is fried right now.
Thanks for the help.