I am running a search with a dynamic WHERE and it is missing code when I echo out the SELECT, Can someone point out why??
if(empty($zip_code)) {
$where = "WHERE user.bd_year <= $year1 AND user.bd_year >= $year2 AND user.gender = $genderPref AND user.genderPref = $gender ";
if (!empty($smoke))
{
$where .= " AND about_me.smoking = $smoke";
}
if (!empty($religion))
{
$where .= " AND bkgd.relg = $religion";
}
if (!empty($heightMin))
{
$where .= " AND appearance.height >= $heightMin";
}
if (!empty($heightMax))
{
$where .= " AND appearance.height <= $heightMax";
}
if (!empty($hairColor))
{
$where .= " AND appearance.hair_color = $hairColor";
}
if (!empty($eyeColor))
{
$where .= " AND appearance.eye_color = $eyeColor";
}
$result = mysql_query("SELECT user.userID, user.gender, user.genderPref, user.city, user.state, photos.photo_1,
CURDATE(), (YEAR(CURDATE())-YEAR(birth_date)) - (RIGHT(CURDATE(),5) < RIGHT(birth_date,5)) AS age
FROM user
LEFT JOIN photos
ON user.userID = photos.userID
LEFT JOIN about_me
ON user.userID = about_me.userID
LEFT JOIN bkgd
ON user.userID = bkgd.userID
LEFT JOIN appearance
ON user.userID = appearance.userID
$where")or die(mysql_error());
} // end of empty($zip_code)
the SELECT...
SELECT user.userID, user.gender, user.genderPref, user.city, user.state, photos.photo_1, CURDATE(), (YEAR(CURDATE())-YEAR(birth_date)) - (RIGHT(CURDATE(),5)= 1911 AND user.gender = 2 AND user.genderPref = 1
this is the $where, it is missing the bolded text
WHERE user.bd_year <= 1992 AND user.bd_year >= 1911 AND user.gender = 2 AND user.genderPref = 1