How do I get values from a table out of a foreach loop?
<p>What I'm doing is trying to set up a page where users can see their created tools and delete them whenever they want.  I'm querying three different tables and putting the results into an array.  Once those values are in an array, a foreach loop goes through and populates a table with all the information in a table, like so: </p>

<pre><code>    $counter = 1;
    echo '&lt;table&gt;'
    foreach ($recent_saved_tools as $key =&gt; $value) {

            echo '&lt;tr name="item'.$counter.'"&gt;';
            echo '&lt;td&gt;';

            echo '&lt;input type="hidden" name="tablename" value="'.$value['table'].'" /&gt;';
            echo '&lt;input type="hidden" name="tabledelete" value="'.$value['delete'].'" /&gt;';
            echo '&lt;input type="hidden" name="tableidfield" value="'.$value['idfield'].'" /&gt;';
            echo '&lt;input type="hidden" name="tableid" value="'.$value['id'].'" /&gt;';

            //code to display the tool name and link
            echo '&lt;a style="text-decoration:none;" href="'.WEBSITE.'tools/'.$value['URL'].'?saved_data_id='.$value['id'].'"&gt;'.$value['display'].'&lt;/a&gt;&lt;br /&gt;';
            echo date("m/d/Y H:i:s", $key).'&lt;br /&gt;';
            echo '&lt;/td&gt;&lt;td&gt;';

            //code to display the delete button
            echo '&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input class="cssformbutton bluebutton" type="button" name="delete" id="deletebtn'.$counter.'" value="Delete" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/td&gt;';

            $counter ++;

    }
    echo '&lt;/table&gt;';
</code></pre>

<p>The problem is whenever I run the SQL query, no matter what button I click it always takes the values from the last table row.  I know it has something to do with the way they're named (multiple elements have the same name) but I'm at a loss on how to fix this.  Any help would be appreciated.</p>

<p>Here's the query I'm using to delete the item:</p>

<pre><code>$query = 'UPDATE '.$value['table'].' SET '.$value['delete'].' = 1 WHERE '.$value['idfield'].' = '.$value['id'];

$sql-&gt;query($query);
</code></pre>

<p>EDIT: added delete code</p>
