-2

Firstly, I am a novice as my name suggests so forgive me if I don't phrase what I am asking correctly!

I am an owner of a website which has products dynamically inserted into the database each night.

From the datafeeds pulled in, we make rules to EXCLUDE certain products within the feeds.

I am trying to add variants to these rules, but whenever I try to add in the variants using the 'or' operator that I looked up, nothing works at all, and in fact, nothing pulls through to the database.

Currently this is what is live and works:

    if ($gender == "Female" AND $display_price != null AND $kids != "Children")

('Female' products pulled in, but ignore/delete anything marked as 'Female" and 'Children')

I want to add variants in so that we can include products that don't fit the above criteria because a different label is used and have tried these with no success:

    if ($gender == "Female" OR $gender == "Women") AND $display_price != null AND $kids != "Children" OR $kids == "Kids")

also tried:

    if ($gender == "Female" || $gender == "Women") && $display_price != null && $kids != "Children" || $kids == "Kids")

So basically I want to pull in any 'Female' or 'Women' clothing products but ignore anything which is kid's clothes.

Any suggestions?

Thanks in advance!

EDIT

Sorry guys, I should clarify I am not the developer obviously, he is out-of-action at the moment working on another big project.

Apologies if I mis-titled the topic.

But I am competent enough to make small cut and paste changes like this, I think!

  • 1
    very odd sounding db structure –  Jul 10 '13 at 10:58
  • Look up `if` statements. Your if condition needs to be wrapped in parenthesis: `if (conditions)`. In your latter statements, I see `if (conditions)conditions)`. – BLaZuRE Jul 10 '13 at 11:00
  • 1
    The title asks about OR but in the question body you only seem to care about making it work. Clarify the question title or the body please. In any case: http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php – Gordon Jul 10 '13 at 11:01

7 Answers7

4

Looks like you forgot brackets:

if (($gender == "Female" || $gender == "Women") && $display_price != null && $kids != "Children" || $kids == "Kids")
Jesbus
  • 790
  • 8
  • 24
  • u forgot to add kids in separate brackets, kids have an or option too – sven Jul 10 '13 at 11:04
  • Hi Jesbus, I copied and pasted your first response and it worked, then I was trying out some other responses just to see how they affected things. – Complete Novice Jul 10 '13 at 11:38
  • Sorry, went back to your solution, think you might have changed it, now the new line above does not work for me! Can you share your original solution please? – Complete Novice Jul 10 '13 at 11:39
  • Ok, I changed it back again – Jesbus Jul 10 '13 at 12:01
  • This worked in the end for me, thanks very much for your help! if (($gender == "Female" || $gender == "Women") && $display_price != null && $kids != "Children" && $kids != "Kids") – Complete Novice Jul 10 '13 at 15:37
1
if (($gender == "Female" OR $gender == "Women") AND $display_price != null AND $kids != "Children" OR $kids == "Kids")
Black Sea
  • 124
  • 1
  • 9
0

Aren't you getting an error in your above code, you are using

if ($gender == "Female" OR $gender == "Women") AND $display_price != null AND $kids !="Children" OR $kids == "Kids")

rather it should be

if ( (condition1 or condition2) and condition3 and condition4 and (condition5 or condition6) )

In your case

if ( ($gender == "Female" OR $gender == "Women") AND $display_price != null AND ($kids !="Children" OR $kids == "Kids") )

the two conditions having "or" needs to be in separate brackets, within the whole condition

sven
  • 775
  • 5
  • 14
0

I think your problem is that you are missing several brackets.

Try:

if (($gender == "Female" || $gender == "Women") && $display_price != null && ($kids != "Children" || $kids == "Kids"))
Baxny
  • 576
  • 7
  • 12
0

Your are missing an openening parenthesis in both statements:

if (($gender == "Female" OR $gender == "Women") AND $display_price != null AND $kids != "Children" OR $kids == "Kids")

d-stroyer
  • 2,638
  • 2
  • 19
  • 31
0

Here is what u can try

 if($gender == "female" || $gender=="male" AND $display_price!=NULL){

    if($kids != "Children"){
    // Here will be item for the male or femaile with not price=Null and kids not==children
    }

    }
Ahmed Habib
  • 189
  • 11
0

First of all your new IF Condition is syntactically wrong as it doesn't contains opening bracket in IF condition.

Secondly try this condition,

if (($gender == "Female" || $gender == "Women")
 && $display_price != null
 && ($kids != "Children" && $kids != "Kids"))
{
 //Your Code.
}
Nitesh Mishra
  • 311
  • 1
  • 10