Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP && or if else statement not working correctly
    primarykey
    data
    text
    <p>So I have this survey that I am pulling results from and I have to basically make a bunch of <code>if...else if...</code> statements involving which feedback is submitted.</p> <p>I have set it up to work correctly...except for one problem. I know it's probably something stupid, but for the life of me I can't figure it out.</p> <p>Anyways here is the code.</p> <pre><code>if (($QID_A == 23) &amp;&amp; ($row_result_2['Feedback'] == "")) { echo ""; } else if (($QID_A == 23) &amp;&amp; ($row_result_2['Feedback'] &lt;= 3)) { echo $row_custom['Content']; } else if (($QID_A == 23) &amp;&amp; ($row_result_2['Feedback'] == 4) || ($row_result_2['Feedback'] == 5) || ($row_result_2['Feedback'] == 6)) { echo $row_custom['Content2']; } else if (($QID_A == 23) &amp;&amp; ($row_result_2['Feedback'] &gt;= 7)) { echo $row_custom['Content3']; } </code></pre> <p>The problem I am getting is if <code>$row_result_2['Feedback']</code> is <code>==</code> to 5 or 6. It just repeats the line over and over again, basically failing to evaluate. It works fine for 4, so I am thinking my problem is somewhere in how I set up the <code>||</code> statements?</p> <p>Any help would be appreciated. Thank you.</p> <p>While I'm at it would there be a simpler way to write this statement? So i don't have to copy it for each <code>QID_A</code> field 1-50?</p> <p>UPDATE:: At this point I am at a loss as to why none of the below solutions are working.. I think this might be a deeper issue as the results are still repeating 24 times... Being that QID_A is 23 I think this might be related.. but I can't seem to find a connection... Thanks again for the help though guys I appreciate it.</p> <p>Just for the hell of it I tried writing the statements out individually.... same result... for example.</p> <pre><code>if (($QID_A == 22) &amp;&amp; ($row_result_2['Feedback'] == "")) { echo ""; } else if (($QID_A == 22) &amp;&amp; ($row_result_2['Feedback'] &lt;= 3)) { echo $row_custom['Content']; } else if (($QID_A == 22) &amp;&amp; ($row_result_2['Feedback'] == 4)) { echo $row_custom['Content2']; } else if (($QID_A == 22) &amp;&amp; ($row_result_2['Feedback'] == 5)) { echo $row_custom['Content2']; } else if (($QID_A == 22) &amp;&amp; ($row_result_2['Feedback'] == 6)) { echo $row_custom['Content2']; } else if (($QID_A == 22) &amp;&amp; ($row_result_2['Feedback'] &gt;= 7)) { echo $row_custom['Content3']; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload