I need help with programming the conditional logic for the following problem in PHP:
This file lists ~20 questions each with multiple checkboxes to end user. The end user will select various checkboxes for various questions and on submit the page will return the total count of users that fit that criteria.
If the end user selected multiple options in the same question then the options are “OR’ed”. EX: Return count of all users who selected Option 1 OR Option 3 on Question 5
If the end user selected options from multiple questions then the questions are “AND’ed”. EX: Return count of all users who selected Option 4 on Question 2 AND Option 1 on Question 7
Advanced test case: Return count of users who answered (Option 1 OR Option 3 on Question1) AND (Option 2 OR Option 3 on Question 4) AND (Option 1 on Question 7).
The report.php file will post to process.php which I need to develop.
First, I need to capture all the variable data. I was going to _REQUEST all 100 or so variables but then thought about using explode on the _POST and loading the responses into an array. Any recommendations?
Then, I want to construct the query that will handle the above conditional logic. I was going to construct a string ($where) that contains something like this:
WHERE (q1=1 || q1=3) AND (q4_2 = 1 || q4_3 = 1) AND (q7 = 1)
Please help me understand the best way of implementing this. PHP or psuedocode would really be beneficial. Your time is much appreciated and thank you in advance.