3
Hello.
I want to create a CRUD that does word management and its synonyms. A word has several synonyms (1:N).
I would like a solution to dynamically include the inputs, according to the demand of each user. For example, one word to be registered has 3 synonyms, while another word has 10 synonyms. There in the first example, 3 fields would be created, and in the second, 10 fields.
How to make this form and how to insert this data into the database? I am using PHP + Mysql.
What have you tried?
– Jéf Bueno
I tried to put a form with a field for the user to enter the number of synonyms, then send via Post and show the registration form with the right number of fields. But I did not find this solution good, until pq I will have to make another form that this situation will repeat more than once.
– LauBF
you have doubt on how to add one more
input text
? and how to receive in php?– rray
I would like a solution to dynamically include inputs, according to the demand of each user. For example, one word to be registered has 3 synonyms, while another word has 10 synonyms. There in the first example, 3 fields would be created, and in the second, 10 fields.
– LauBF
Aaaaaah now yes, I think everyone understood what you. To 'duplicate' the inputs it is necessary to use javascript or jquery, an important detail the name of this input had the brackets ex:
'<input type="text" name="sinonimo[]" />
so php will understand that it’s an array. You can do a simple test, create two text with the same name and then do the one foreach in php, exforeach($_POST['sinonimo'] as $item){ echo $Item.'<br>';}
. Edit your question and put part of your comment on it, it will make it easy for someone to answer.– rray
I’ll edit it, thank you.
– LauBF
You can start with Clone data insertion box from with jQuery and Pass variables with same name to PHP
– rray
The question is cool now, it can be better if you put part of the code you did, if it didn’t start try :). Go in stages, first mount the form and only, then try to make the code that assembles the dynamic inputs work, receive the values in php and finally write to the database.
– rray
I managed to do. Thank you very much!
– LauBF