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.

Link to comment
Share on other sites

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";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.