I have read some of the posts my search came up with but some were beyond my knowledge and others didn't seem to help. I want to search a table in my database using five variable that I get from a form. It works when I enter one but it I enter two the search fails. They are drop down boxes that match the database perfectly so I am not sure where I went wrong.
mysql_connect($host, $user, $password);
@mysql_select_db($database) or die("Unable to select database");
$query="SELECT * FROM `VictimEmail` WHERE ";
if($id)
$query.="ID ='$id'";
if($name)
$query.="Name LIKE '$name'";
if($state)
$query.="State LIKE '$state'";
if($treatment)
$query.="Treatment LIKE '%$treatment%'";
if($subject)
$query.="Subject LIKE '$subject'";
$result=mysql_query($query)
or die ("Query Failed");
$num=mysql_num_rows($result);
mysql_close();
Any advise would be greatly appreciated and thanks in advance for your help.