We are using MySql and PHP for a genealogy photograph database. When trying to search for a photo, using a persons first and last name. Using the script below, it works fine, if the person we are searching for is the first person listed in the photo.
$sql_text = ("SELECT * from photo WHERE lname LIKE '$last%'
AND fname LIKE '$first%'
However if we use the OR command such as in the script below, to search for other people listed in the photo, we end up getting all the photo's where the last name is used, and it ignores the search for the first name.
$sql_text = ("SELECT * from photo WHERE lname LIKE '$last%'
OR o1last LIKE '$last%'
OR o2last LIKE '$last%'
OR o3last LIKE '$last%'
AND fname LIKE '$first%'
Does anyone have any ideas how we can fix this?