2
I have an array of inputs and use to record in the database
/*ANSWERS */
foreach($params['questionnaire_questions_answers'] as $key => $item){
$student_anamineses_answers = DB::table('student_anamineses_answers')->insert(
array(
'student_anamnese_id' => $id,
'questionnaire_question_id' => 2,/*VER COMO GRAVAR O questionnaire_question_id DINAMICAMENTE */
'answer' => $item
)
);
}
/*ANSWERS */
The problem is questionnaire_question_id is in another input:
<input type="hidden" name="questionnaire_question_id[]" value="'+ item.id +'" />\
<textarea required name="questionnaire_questions_answers[]" cols="80"
placeholder="Digite a resposta aqui" rows="3" id="perguntas"></textarea>')
It is a question and answer system. I record the question table called Question and then need to record the answers in the Answers tables. I do a foreach to get the id of the questionnaire_questions_answers textarea so I can save the answer to the Answers table. Only I need to get the question id, q I pass the questionnaire_question_id input. When I do a foreach in the textareas I can take the data (Answers) and record in the bano, but I don’t know how to take the id of the question and record in the same table Answers. How to go through this input and save the information in questionnaire_question_id?
I did not understand well, the problem, this input it is sent along with the other data ? can explain the process that is happening, the question is a little vague.
– Bulfaitelo
Also not understand very well what you want, you want to access the
questionnaire_question_id
which is associated withquestionnaire_questions_answers
? If so when walking through one keep theindex
and use in the array of the other element. I think you want to do thisquestionnaire_questions_answers[0]
questionnaire_question_id[0]
– lazyFox
edited the question to see if it facilitates the understanding
– Edinho Rodrigues