title: inputs in form created with foreach in PHP, how to pass all input values with post method?
body: <p>I created a form, where my inputs are created by a foreach loop with data coming from a mysql database.</p>
  
  <p>When the form is submitted with method post, I want to be able to receive all the info through $_POST, but currently I'm only receiving the info from the last created input in the foreach loop.
  The variable $fishes comes from mysql database and contains 8 rows, so the foreach loops 8 times.</p>
  
  <p>My goal is to insert this data in a database table, so I can recall it.
  When i run my XDebug after pressing submit, my $_POST contains action: insertFish and quantity: (value from input of last iteration in foreach).</p>
  
  <p><a href="https://i.stack.imgur.com/oaMOH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oaMOH.png" alt="my global Post"></a></p>
  
  <p>I would also like to be able to see the label with the corresponding quantity. I thought by adding a label would work but it didn't.</p>
  
  <p>My form:</p>
  
  <pre><code>&lt;form class="fishadd__form" action="index.php?page=fishtanks&amp;id= &lt;?php echo $_SESSION['tank_id']; ?&gt;" method="post"&gt;
  &lt;input type="hidden" name="action" value="insertFish"&gt;
  &lt;div class="fishadd__box--wrapper"&gt;
  
  &lt;?php foreach($fishes as $fish): ?&gt;
    &lt;div class="fishadd__box"&gt;
      &lt;h2 class="fish__name"&gt;&lt;?php echo $fish ['name']?&gt;&lt;/h2&gt;
      &lt;img class="fish__picture" src="../src/assets/img/goldfish.svg" alt="Goldfish" width="125"&gt;
      &lt;div class="item__counter"&gt;
        &lt;div class="fishadd__bottom"&gt;
        &lt;button class="minus__button"&gt;-&lt;/button&gt;
        &lt;label for="quantity" name="&lt;?php echo $fish['name']?&gt;"&gt;
        &lt;input class="fishadd__input" type="number" name="quantity" min="0" value="0"&gt;
        &lt;/label&gt;
        &lt;button class="plus__button"&gt;+&lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;?php endforeach; ?&gt;
   &lt;/div&gt;
   &lt;button type="submit" class="add__fish" value="submit"&gt;add to tank&lt;/button&gt;
   &lt;/form&gt;
  </code></pre>