Hi!
Ive got a search-form that I cant get to work the way I want.
It consist of two text-fields and a date-picker(two fields with a start date and a end date).
The problem I have is that I cant get it to work if you enter a criteria in more than one of the fields. Ie I can either search for "food", but not "food"(in the fÃrst field) and "pizza"(in the second). Can't use the date-picker with any of them. It works if I only use one of the criterias.
Code:
if($nydatum1 != '--' or $nydatum2 != '--')
{
$sel_sok = mysql_query("SELECT * FROM container WHERE datum BETWEEN '$nydatum1' AND '$nydatum2' OR fraktion LIKE '$_POST[fraktion]' OR ort LIKE '$_POST[ort]'") or die(mysql_error('Fel vid sökning!'));
}
else
{
$sel_sok = mysql_query("SELECT * FROM container WHERE ort='$_POST[ort]' OR fraktion LIKE '$_POST[fraktion]' OR ort LIKE '$_POST[ort]'") or die(mysql_error('Fel vid sökning!'));
}
Ive made two "SELECT"-lines depending on if the date is set or not, but if I dont need it, Ill drop it for a better solution :)
Thanks in advance!
/Hylsan