Question about database and multiple similar inputs in a form


Im currently creating a recipe app, but i have a few problems which I need help on.

Firstly, I have a form whereby I want the user to be able to input all the ingredients shown in this screenshot -

. Initially, I wanted to have a scenario whereby users can keep adding ingredients, but i wasn’t sure how. Hence I ended up creating a database called “Ingredients” of which the properties contains Ingredients 1 to 10 and their respective quantity and measurements as shown here - .

However, when i tried to include the ingredient count in my recipe details page, the count wasn’t registered correctly, ie even though i’ve added three ingredients, the total count is only one.

Hence what i need help on is:

  1. Whether there is a way to create a form whereby users can click the + button to continue adding ingredients endlessly
  2. Why is my ingredient count not showing up correctly in my recipe details page?

Happy to provide more information if needed and really appreciate all the help!

You need to setup a relationship property between an ingredients collection and a recipes collection. A recipe can have many ingredients and an ingredient can have many recipes.

This will also solve your count problem as the way you set it up makes it impossible to count as it is essentially always a single value.

Does this mean i have to create one database for Ingredient 1, another database for Ingredient 2 and so on?

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.