Jump to content

[SOLVED] Query with some type of IF statement???


tekrscom

Recommended Posts

I'm not even sure if this is possible or not, but somehow I have to get an IF statement inside of a query or find an alternative... So, here's my query...

//Just for reference
$query="";
if ($_SESSION['SearchParameter'][4]==1){$query=$query."Old=1, ";}
if ($_SESSION['SearchParameter'][5]==1){$query=$query."Fat=1, ";}
if ($_SESSION['SearchParameter'][11]==1){$query=$query."Bukkake=1, ";}
if ($_SESSION['SearchParameter'][12]==1){$query=$query."Bondage=1, ";}
if ($_SESSION['SearchParameter'][13]==1){$query=$query."Cuckold=1, ";}
if ($_SESSION['SearchParameter'][22]==1){$query=$query."Gay=1, ";}
if ($_SESSION['SearchParameter'][23]==1){$query=$query."BiSexual=1, ";}
if ($_SESSION['SearchParameter'][24]==0){$TempGender='Either';}
if ($_SESSION['SearchParameter'][24]==1){$TempGender='Male';}
if ($_SESSION['SearchParameter'][24]==2){$TempGender='Female';}
if ($_SESSION['SearchParameter'][25]==0){$TempPrivacySetting="";}
if ($_SESSION['SearchParameter'][25]==1){$TempPrivacySetting=" AND Users.PrivacySetting = 'Public'";}
$query = substr_replace($query," ",-2);
//The query
$sub_query = "SELECT Interests.*, Users.* ".
"FROM Interests RIGHT JOIN Users ".
"ON Interests.UserID = Users.UserID WHERE Users.Gender = '$TempGender' $TempPrivacySetting AND $query ORDER BY LogOnDate DESC";

 

Now what I'm trying to add to this query here is to eliminate results where the Users.Yahoo and Users.MSN are both blank.

In the WHERE add:

 

AND (Users.Yahoo!='' AND Users.MSN!='')

 

Wes

 

Yeah, don't know why that evaded me, that sounds perfectly logical... but it doesn't work... It only produces a result if the User has both a Yahoo and an MSN... Not if they are missing both... Here's what I did with the query...

$sub_query = "SELECT Interests.*, Users.* ".
"FROM Interests RIGHT JOIN Users ".
"ON Interests.UserID = Users.UserID WHERE Users.Gender = '$TempGender' $TempPrivacySetting AND (Users.Yahoo!='' AND Users.MSN!='') AND $query ORDER BY LogOnDate DESC";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.