harkly
11-22-2011, 09:23 PM
I have this search and it is working, but now I need to add one more thing to it and I just can't get it to work.
I need to add code to prevent a user showing if they are in the 'blockUser' table
I thought I could add that to the bottom of the $wheres but it doesn't work. Tried some different things as well.
this is the code I was trying to work with::
if (!isset($blockID)) {
$where .= " AND blockUser.blockID = user.userID";}
my search code::
$z = new zipcode_class;
$zips = $z->get_zips_in_range($zip_code, $miles, _ZIPS_SORT_BY_DISTANCE_ASC, true);
$zips_in_range = implode(',', array_keys($zips) );
$where = "WHERE zip IN (". $zips_in_range .") AND user.bd_year <= $year1 AND user.bd_year >= $year2 AND user.gender = $genderPref AND user.genderPref = $gender AND user.exp_date >= CURDATE() ";
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
LEFT JOIN blockUser
ON user.userID = blockUser.blockID
$where
LIMIT $offset, $rowsperpage")or die(mysql_error());
I am not sure if it is a simple issue or if I am way off, could use some help
I need to add code to prevent a user showing if they are in the 'blockUser' table
I thought I could add that to the bottom of the $wheres but it doesn't work. Tried some different things as well.
this is the code I was trying to work with::
if (!isset($blockID)) {
$where .= " AND blockUser.blockID = user.userID";}
my search code::
$z = new zipcode_class;
$zips = $z->get_zips_in_range($zip_code, $miles, _ZIPS_SORT_BY_DISTANCE_ASC, true);
$zips_in_range = implode(',', array_keys($zips) );
$where = "WHERE zip IN (". $zips_in_range .") AND user.bd_year <= $year1 AND user.bd_year >= $year2 AND user.gender = $genderPref AND user.genderPref = $gender AND user.exp_date >= CURDATE() ";
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
LEFT JOIN blockUser
ON user.userID = blockUser.blockID
$where
LIMIT $offset, $rowsperpage")or die(mysql_error());
I am not sure if it is a simple issue or if I am way off, could use some help