title: $_POST superglobal in foreach loop not working
body: <p>With below code I select a quantity, then I check the Item whose quantity I have selected then I click the add button to submit the form.</p>
  
  <pre><code>&lt;form name="addtocart" method="post" action="checkbox.php"&gt; 
  
  //foreach loop below loops through array of items fetched from the db
  &lt;?php foreach($result2 as $row) { ?&gt;
  
  &lt;select name="qty"&gt;
  &lt;?php for ($i=0; $i &lt; $row['prd_quantity'] + 1 ; $i++) { ?&gt;
  &lt;option value = "&lt;?php echo $i; ?&gt;" &gt;&lt;?php echo $i; ?&gt;&lt;/option&gt;;    
  &lt;?php }?&gt;
  &lt;/select&gt;
  
  &lt;input type="checkbox" name="checkitem[]" id="addtocart"  value="&lt;?php echo   $row['prd_id'] ?&gt;" optional /&gt;&lt;/p&gt;
  
  &lt;?php } ?&gt;
  enter code here
  &lt;input type="submit" value="Make Order"/&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>After selecting, say 8 on the select element, $ordqty below still outputs 0. I am thinking its something to do with the loop and <code>$_POST</code> superglobal but </p>
  
  <blockquote>
    <p>checkitems[ ]</p>
  </blockquote>
  
  <p>works. Help would be appreciated. Thanks. </p>
  
  <pre><code>$ordqty = $_POST['qty'];
  //$ordqty returns 0.
  </code></pre>
  
  <p>Below is the HTML Generated for the first item whose <code>$row['prd_quantity'] = 8</code> :</p>
  
  <pre><code>&lt;select name = "qty"&gt;
  
  &lt;option value="0"&gt;0&lt;/option&gt;
  ;
  &lt;option value="1"&gt;1&lt;/option&gt;
  ;
  &lt;option value="2"&gt;2&lt;/option&gt;
  ;
  &lt;option value="3"&gt;3&lt;/option&gt;
  ;
  &lt;option value="4"&gt;4&lt;/option&gt;
  ;
  &lt;option value="5"&gt;5&lt;/option&gt;
  ;
  &lt;option value="6"&gt;6&lt;/option&gt;
  ;
  &lt;option value="7"&gt;7&lt;/option&gt;
  ;
  &lt;option value="8"&gt;8&lt;/option&gt;
  ;
  &lt;/select&gt;
  </code></pre>