0
I’m creating a recipe site, where the ingredients will be registered individually in a table, referencing the recipe id, example of how the tables are:
ptp_receitas
id|nome
1 |receita de feijão
ptp_receitas_ingredientes
id|id_receita|ingrediente
1 | 1 | feijão
2 | 1 | bacon
3 | 1 | cebola
I created a form that inserts the values in the database, but I don’t know how to insert each ingredient in a new line.
I thought of something with ajax, putting an input "ingredient" that adds the values in a multiple select, and after registering the recipe, it takes each value from that list and inserts a line into the ingredients ptp_receitas_ingredients, something like that:
<input id="ingrediente">
<button id="add_ingrediente" type="button">Adicionar Ingrediente</button>
<select id="ingredientes" multiple>
</select>
<input id="nome_receita">
<button id="cadastrar_receita" type="submit">Cadastrar Receita</button>
Is that the line of reasoning for my need? Or is there another way to do it?
Thank you!
Post the php you use to insert into the bank, it is necessary to formulate a proper response
– Everton Neri