I have a large form with many questions, the answers are either y (for yes), n (for no) or x (for N/A).
The form table is structured as
IPC1 | Question | radio for y, no or x
IPC2 | Question | radio for y, no or x
etc etc
RS1 | Question | radio for y, no or x
RS2 | Question | radio for y, no or x
etc etc
What I need to do is work out the percentage of yes's for all questions with IPC in the name that has either a yes or no response (completely ignore N/A).
I am doing this by updating counters for each question?
etc for all questions with IPC in the radio name. I repeat the above for all questions with RS in the radio name.
I then work out the percentages
Is it possible to do this better as some sections have upto 30 questions which at 5 rows per question to work out the number of completed answers and also the percentage of yes's makes for a very large file.
Many thanks
The form table is structured as
IPC1 | Question | radio for y, no or x
IPC2 | Question | radio for y, no or x
etc etc
RS1 | Question | radio for y, no or x
RS2 | Question | radio for y, no or x
etc etc
What I need to do is work out the percentage of yes's for all questions with IPC in the name that has either a yes or no response (completely ignore N/A).
I am doing this by updating counters for each question?
Code:
totalIPCCounter = 0
IPCYesCounter = 0
if ($_POST['IPC1'] == 'y') {
totalIPCCounter ++;
IPCYesCounter ++;
} elseif ($_POST['IPC1'] == 'n') {
totalIPCCounter ++;
}
if ($_POST['IPC2'] == 'y') {
totalIPCCounter ++;
IPCYesCounter ++;
} elseif ($_POST['IPC2'] == 'n') {
totalIPCCounter ++;
}
etc for all questions with IPC in the radio name. I repeat the above for all questions with RS in the radio name.
I then work out the percentages
Code:
IPCPercentage = (IPCYesCounter / totalIPCCounter) * 100
Is it possible to do this better as some sections have upto 30 questions which at 5 rows per question to work out the number of completed answers and also the percentage of yes's makes for a very large file.
Many thanks