Forum Moderators: open
Take form questions and insert them into a database which is easy. Then take the data from the database and combine certain questions to get a average in a different column.
i.e. question --> do you agree with this person?
strongly disagree, disagree, mildly disagree, mildly agree, agree, strongly agree
They would pick one and it would be inserted.
Now I would take question 1-5 and average them out and display the results.
I have worked with phpmyadmin some but am not sure how to go about combining data and would like the helpful adivice of this board since their are alot more people with more.
Also is there any good tutorials on the subject anyone can recommend.
In your example you said the chioces to a questions was something like:
strongly disagree, disagree, mildly disagree, mildly agree, agree, strongly agree
What you want to do is aassign each one of these a numeric value and store that in a lookup table. So rather then storing "strongly disagree" you store a 1 and instead of "strongly agree" you store a 7. Then what you do is run a query like this:
Select
AVG(agree_level)
from
table
where
this = that
So if this above query returns a 3 then you know the average is "mildly disagree".
Hope this helps
When you set up the SQL query it should be part of that statement, it is an SQL function. Not sure how this looks in php but it is something like.
sql.execute(select avg(agree_level) from table)
Sorry I don't know PHP but if you ask someone in the PHP section to give you the syntax for this sql then you will have what you need. but if you were to execute this statement directly it will gve you want you want.
Select
AVG(agree_level)
from
table
where
this = that