So i created a quiz but i need some help to solve a problem I am having... I have the quiz right now so that it saves the answers but what I would like to do is take all of the answers and determine which one was chosen more then the other to get the result... For example... What color do you prefer: -yellow -blue -red -black and the value to each option would be a1, a2, a3, a4... so what I am looking to do is say there is 5 questions and someone chooses a1 3 times and a3 2 times then there result would be a1... so I need to find a PHP snipit that will count the results and determine which one has been chosen the most and print it out... Anyone have any ideas or anything like this? Any help at this point would be appreciated...
Do you mean you want to ask the same question multiple times and find which is the most popular or do you want a script that has multiple questions on one page and you want to know from options 1 - 5 which number is the most answered?
No... Let me explain a little bit better for you to understand... I have a quiz that I have created... I am looking to create the results page now to tally up the result... there are 6 questions to the quiz and each question will have 4 multiple choice options... each multiple choice option will have the value of a1-4 which will be the same for every question.... Now since there are 6 questions what I al looking to do is make some kind of php script which will look at all the answers and for example say someone choose a4 on 5 of the questions and choose a1 on one of the questions then I will need php to check this and then see that a4 was choosen the most so it will print out the result for a4... If someone has any ideas on how I can further more do this in php then please can you help me out...
Submit all the values to php as an array of values then use array_count_values to tally them all up and then use asort to sort the array, and use the last value's key
Do you have any examples just off hand... There are many ways to do this using an array but maybe the way you are thinking of might be a bit easier then what came to my mind...
I don't. I've given you the steps above of exactly what I was thinking. If you want me to make you a script it would be chargeable (PM me if you do)
Okay... Thats fine... I have taken your advice so far and seems to be alright... If I run into any further problems then I will be sure to shoot you off a PM... Thanks for your assistance...
If this result is for single user, the solution will work perfect. But if you want to choose answer using the logic you mentioned for the answers given by multiple users, then it better be taken from database where you have stored all the answers. I am not sure if I have got it right, but hoping to hear from you that the problem is sorted out