Hi,
I’m trying to build a survey system. Administrators will be able to create surveys for the customers to respond to. Each survey response is associated with a Company and can be given a name. I need to be able to save those responses to a MySQL database.
I was thinking of adding each answer as a new row to a response_answers table but at the same time save the details of the overall questionnaire response to a response_questionnaires table; then the two will be linked.
I think where I am starting to struggle (well i’ve been struggling for a while now) is the fact that the survey would be able to contain differing numbers of questions, i guess i would need to use some sort of repeat region to add these.
So the two tables are structured like:
response_questionnaires: id, questionnaire_id, response_name, s_id
Where id is the primary key, questionnaire_id is the id of the questionnaire made by the admin, response_name is the name the customer can apply to that response and s_id is the company id.
response_answers: ra_id , r_id, answer_id
Where ra_id is the primary key, r_id is the questionnaire response id as set in the response_questionnaire table, and answer_id is the id from the answers table which links to the text and other details for the selected answer.
I have the code for adding in the response_questionnaire details, and then i was going to use LAST_INSERT_ID to add that to each row in the response_answers table along with the value of the answer checkbox/radio button.
Would this work by splitting the POST array into its component parts and then using a foreach?
I am coming back to php after several years off, so this is almost all new to me (and i have been using dreamweavers bindings up until now).
I hope that all made sense,
thanks