I am inserting data to the database using a for Loop, I am having data stored in Array to insert into table (ex.- questionIdArray) I am sharing my code below. Is this approach correct or should I refine this.
$retriveDataForJSON= mysql_query($querytoGetUsageOfSelectStudents);
while ($row = mysql_fetch_array($retriveDataForJSON))
{
$USER_ID= $row["USER_ID"];
$SESSION_ID= $row["SESSION_ID"];
$QUESTION_IDS = $row["QUESTION_IDS"];
$questionIdArray=explode(',',$QUESTION_IDS);
$RESPONSES= $row["RESPONSES"];
$responseArray=explode('|',$RESPONSES);
$RIGHT_OR_WRONG = $row["RIGHT_OR_WRONG"];
$rightWrongArray=explode('|',$RIGHT_OR_WRONG);
$TIME_PER_QUESTION = $row["TIME_PER_QUESTION"];
$timePerQuestionArray=explode('|',$TIME_PER_QUESTION);
$QUIZ_SIZE = $row["QUIZ_SIZE"];
$CORRECT_ANSWERS = $row["CORRECT_ANSWERS"];
$COURSE_ID= $row["COURSE_ID"];
$TOPIC_NAME = $row["TOPIC_NAME"];
$SUBTOPIC_IDS = $row["SUBTOPIC_IDS"];
//$subtopicNameArray = getSubtopicNameArray(subtopicIds)
//$topicNameArray = getTopicNameArray(subtopicIds)
$START_TIME = $row["START_TIME"];
$END_TIME = $row["END_TIME"];
$TIME_TAKEN = $row["TIME_TAKEN"];
for($i=0;$i<sizeof($questionIdArray);$i++){
//Insert Query To Temp Table
$queryToInInsertInTable= "INSERT INTO `temp_assessment_data`(`Q_ID`, `RESPONCE`, `W/R/B`, `TIME_TAKEN`, `USER_ID`, `TOPIC`, `SUBTOPIC`, `CLASS`, `SCHOOL`, `BLOCK`, `DISTRICT`) VALUES
('$questionIdArray[$i]','$responseArray[$i]','$rightWrongArray[$i]','$timePerQuestionArray[$i]','$USER_ID','$className','$schoolName','$blockName','$District')";
}