title: using PHP for each to get dynamic values from table
body: <p>It's been a while since I looked at php and I've got a brain block.  I'm trying to get the values from a table using foreach so that I can store the values in a session and also display the number of items that have been ordered.</p>
  
  <p>eg 2 of item number 4 etc</p>
  
  <p>here's the table / form</p>
  
  <pre><code>        &lt;form id="products" method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;
              &lt;?php 
                  //every item from the products table is queried because all fields need to be displayed
                  $sSQL = "SELECT * FROM products";
                  $rsResult = mysql_query($sSQL);
              ?&gt;
              &lt;table id="products_table"&gt;
                  &lt;tr style="font-weight:bold"&gt;
                      &lt;td style="text-align:center"&gt;ID&lt;/td&gt;
                      &lt;td&gt;Ref No.&lt;/td&gt;
                      &lt;td&gt;Product Name&lt;/td&gt;
                      &lt;td&gt;Description&lt;/td&gt;
                      &lt;td style="text-align:right"&gt;Price&lt;/td&gt;
                      &lt;td colspan='2' style='text-align:center'&gt;Add To Order&lt;/td&gt;
  
                 &lt;/tr&gt;
              &lt;!--for each record in the table that matches the query a row is created in the table and the data in the relevant field is displayed--&gt;   
              &lt;?php while ($row = mysql_fetch_array($rsResult)){ ?&gt;
                  &lt;tr&gt;
                  &lt;input type="hidden" name="productID[&lt;? echo $row['productID']; ?&gt;]" value="&lt;? echo $row['productID']; ?&gt;" /&gt;
                      &lt;td style="text-align:center"&gt;&lt;? echo $row['productID']; ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;? echo $row['productReference']; ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;? echo $row['productName']; ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;? echo $row['productDescription']; ?&gt;&lt;/td&gt;
                      &lt;td style="text-align:right"&gt;&lt;? echo '£'. $row['productPrice']; ?&gt;&lt;/td&gt;
  
                      &lt;td style="text-align:center"&gt;&lt;span&gt;Qty&lt;/span&gt;&lt;input type='text' name="qty[&lt;? echo ($_POST['qty']); ?&gt;]" value="" &gt;&lt;/td&gt;
             &lt;? } ?&gt; 
              &lt;/table&gt;
  </code></pre>
  
  <p>Heres the php</p>
  
  <pre><code> &lt;?php 
            foreach($_POST as $key =&gt; $value){
                echo $key . ' ' .$value.'&lt;br /&gt;';
                print_r($key);
            }
  ?&gt;
  </code></pre>
  
  <p>I know that the php is no where complete for filling sessions etc, I just can't work out how to get the values out of the form.  This php was my attempt to try and at least get some kind of value out of it</p>
  
  <p>Any help is greatly appreciated</p>