title: How to extract specific id number from a array of buttons in php?
body: <p>When I run the code below, it generates a table of columns ID, Product, Price and a column with buttons "edit" and another with "delete". When I debug this program via var_dump(), I get a output of e.g.:
  array(1) { [30]=> string(6) "Delete" } or array(1) { [27]=> string(6) "Delete" } with the number in the [] corresponding the the products ID. For the edit column, instead of "Delete" it says "Edit". <strong>My Question is, how do I extract the information outputs button 17(corresponding with ID number) of button "Edit" has been clicked?</strong></p>
  
  <pre><code>echo "&lt;form action='' method='POST'&gt;";
          echo "&lt;table border='0' cellpadding='10'&gt;";
          echo "&lt;tr&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;Product&lt;/th&gt; &lt;th&gt;Price ($)&lt;/th&gt; &lt;th&gt;Edit Menu&lt;/th&gt; &lt;th&gt;Delete Menu&lt;/th&gt; &lt;/tr&gt;";
  
          // loop through results of database query, displaying them in the table
          while($row = mysql_fetch_array( $result )) {
            echo "&lt;tr&gt;";     // echo out the contents of each row into a table
            echo '&lt;td&gt;' . $row['id'] . '&lt;/td&gt;';
            echo '&lt;td&gt;' . $row['name'] . '&lt;/td&gt;';
            echo '&lt;td&gt;' . $row['price'] . '&lt;/td&gt;';
            echo '&lt;td&gt;&lt;input type="submit" value="Edit" name="id1['.$row['id'].']" /&gt;' . '&lt;/td&gt;';
            echo '&lt;td&gt;&lt;input type="submit" value="Delete" name="id2['.$row['id'].']" /&gt;' . '&lt;/td&gt;';
            echo "&lt;/tr&gt;";
            }
            // close table&gt;
            echo "&lt;/table&gt;";
            echo '&lt;/form&gt;';
  
            if(isset($_POST['id1'])) {
              var_dump($_POST['id1']);
            }
  
            if(isset($_POST['id2'])) {
              var_dump($_POST['id2']);
            }
  </code></pre>