Inserting Multiple Rows in one query.

admin

Administrator
Staff member
I have a survey script that adds each response for a survey in a lookup table with two columns: "respondent_id" & "questions_id". (All data is stored in a MySQL database accessed with PHP4 scripts.)

When a survey form is submitted, I loop through all 60 questions and each gets added as a row with "respondent_id" & "questions_id" in this table.

This obviously leads to lots of database connections, i.e. one per answered question.
Is there a more efficient way of doing this?

Same with the displaying of results. Can I use a single SQL query to pull up all the answers and then once this is in memory loop through and assign to variables?

Thanks!!!
Tim
 
Back
Top