Logic Priority / Order

#1

Hi. i have the following logic which works fine
[‘Value’] is equal to 1 or 0
In [‘Text1’] there is text or no text

if ($e['Table']['Value'] == 0) then Option 1

if ($e['Table']['Value'] && $e['Table']['Text1']) then Option 2

if ($e['Table']['Value'] && $e['Table']['Text1'] == false) then Option 3

The problem is that i want to add one more Option which should have highest Priority
It should if any Text in [‘Text3’] regardless if [‘Value’] = 1 or 0
I tried add than one on the top , but as anyone smarter then me would suggest it did not work att all. (-:

if ($e['Table']['Text3'] == true) then Option 4

Please tell me if i am close or very vary far from what i try to do.
Thanks

#2

if you dont want to process your conditions any further, you have to put everything else within an else statement

#3

How exactly are you coming up with these table arrays?

#4

Thanks for advise but if you mean that below it breaks the page.
Text 3 is a columen in the database. Whenever any value in Text 3 i want to set it waking it. whenever no value in Text 3 i want to have the other clauses. Do you thing that is possible at all?
if ($e[‘Table’][‘Text3’] == true) then Option 4
else ($e[‘Table’][‘Value’] == 0) then Option 1
else ($e[‘Table’][‘Value’] && $e[‘Table’][‘Text1’]) then Option 2
else ($e[‘Table’][‘Value’] && $e[‘Table’][‘Text1’] == false) then Option 3

#5

Hay, thank you for answer. I am not sure i understand the question, but these three clauses is what works at the moment on a website. I want to add this 4th clause without breaking as a top priority
if ($e['Table']['Value'] == 0) then Option 1
if ($e['Table']['Value'] && $e['Table']['Text1']) then Option 2
if ($e['Table']['Value'] && $e['Table']['Text1'] == false) then Option 3

4th clause
if ($e['Table']['Text3'] == true) then Option 4

#6

Post an SQL dump of your database with the few sample records. I need to see your database design.

#7

I really do not want to post the SQL dump of the database here. Please give me a hint what is confusing or unclear. At least give me an example how such logic should look like.
Here are the types of columns.
( ['Value'] is tinyint(1)
['Text1'] varchar(200)
['Text3'] varchar(200)

#8

Its simple, I want to know exactly how you are coming up with the data for this…

$e['Table']['Value'] and this kind of thing... $e[‘Table’][‘Text1’]

and all the rest of the values. This smells of a Database design problem. If it is, you need to fix that first. You can always PM me the DB structure.

#9

hi. Ok that might be a database problem, but i was not able to understand why do you think so.
How is that logic supposed to work. Is it what chorn suggested
if ($e[‘Table’][‘Text3’] == true) then Option 4
else ($e[‘Table’][‘Value’] == 0) then Option 1
else ($e[‘Table’][‘Value’] && $e[‘Table’][‘Text1’]) then Option 2
else ($e[‘Table’][‘Value’] && $e[‘Table’][‘Text1’] == false) then Option 3
Please tell me how you think that should work so i can check and if it does not work then conclusion might be there is a DB problem.

#10

I could care less about your attempted solution. If you cant provide what I asked for I am out. We are just going in circles.

1 Like
#11

You forum, your rules. I perfectly understand that you could care less. I see we are in circle and to quickly get out of it I am just asking how similar logic should look like in order to work.

#12

You dont get it. This is an XY Problem. You are asking how to solve your attempted solution rather than providing the information on the real problem. Part of your real problem is probably your database design of which you refuse to provide any information about. Another part of the real problem is how you are coming up with the data arrays, again of which you refuse to provide any information as to how you came up with the arrays. Bottom line, your asking the wrong questions. If you want the correct answer to the REAL problem, then you need to answer what has been asked of you and show what you are working with rather than some snippet that YOU think is what we need to help you.

#13

I did not know what XY problem is. I got help and found the solution. Just had to add else if instead of only else

And it works like a charm

if ($e[‘Table’][‘Text3’] == true) then Option 4
else if ($e[‘Table’][‘Value’] == 0) then Option 1
else if ($e[‘Table’][‘Value’] && $e[‘Table’][‘Text1’]) then Option 2
else if ($e[‘Table’][‘Value’] && $e[‘Table’][‘Text1’] == false) then Option 3

#14

that has nothing to do with the first logic.

#15

To be honest i have no idea and i do not show off or blame. I am a perfect PHP idiot and i do not try to hide it. I am just telling that with else if it works exactly as i need it to

#16

Apparently you cannot even put enough effort into this to click the link I posted that tells EXACTLY what an XY Problem is. I even briefly described it right after the link.

As long as it works, who cares if it’s right, right? You obviously have no desire to learn anything.