Store array in database and recover using one of the array information

Asked

Viewed 410 times

1

I need to develop a system where I capture the selected data from a checkbox and insert everything into a array, I believe this is the most appropriate method for storing, and then send it to the database, and when retrieving the data from the database I would like to simply search for one of the values of the array.

For example I have 3 combobox, a written question 1, question 2 and question 3, if I select only question 1 and 2, this would be recorded in the database, and at the time of recovering the result via SELECT I just put SELECT * FROM tabela WHERE pergunta='pergunta1', and this returns the result in which question 1 is inside the stored array

  • Hello Welcome to Sopt, a look at Tour to see how to post a question, if you can; add more information, code if you’ve ever tried something, so the community can help and not do it for you, good luck.

  • Brother gives to do, it is not difficult, but it is nice you edit your question and put an initial code that is trying... And ask about a specific point... because the way it is, someone will have to assemble the entire script...http://answall.com/tour

  • Not that this is the right way, but in order to help solve this problem quickly and hope that in a future you can improve it, I suggest you, recover your array from the form and turn it into json before sending to the database or even, use the function implode(',', $seu_array) PHP to transform your array in a string separated by ,. Both ways the value will be saved in the database as a string can search using the LIKE '%$pergunta'. As I said, it’s a quick fix, in the future it will complicate your life if you need reports.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.