使用PHP解决动态表单值问题

I have a loop in a form for dynamically adding/removing items, however, only the last item is removed every time. I can add items just fine though.

I can't figure out why no matter which items I try to remove from both add_friends and register_tasks, ONLY the last item is removed. When I echo $_POST['task_name'] it's always the last item on the list, never the one I selected(unless of course I select the last item).

Here is the form

 <center><h2>Create Event</h2></center>
        <form method="post"> 
        <?
        $form = new common_functions();

        if($form->check_saved_forms($my_username, "event") == TRUE){
            $this->existing_forms(); //allow the user to select existing forms that they have created
       }

        ?>               
        <tr><td>Title:</td><td><input type="text" width="20%" name="event_title" value="<? echo $form_data[0]; ?>" /></td></tr>
        <tr><td>Details:</td><td><input type="text" width="20%" name="event_details" value="<?echo $form_data[1]; ?>" /></td></tr>
        <tr><td>Date:</td><td><input type="text" width="20%" name="event_date" id="event_date" value="<? echo $form_data[2]; ?>" /></td></tr>
        <tr><td> <input type="submit" name = "submit_event" id = "lOBut" value="Create Event" /></td></tr>  
        </table>

    <?
    //this is the section giving me trouble
    $form->add_friends($added_friends); 
    $form->register_tasks($tasks,$nums); 
    ?>
    </form>

Both add_friends and register_tasks dynamically add and remove friends/tasks by a textbox, and a list of the added items are shown. users can remove items, however, right now only the last item is removable and I can't figure out why.

Here is register (add_friend is the same, but labeled differently)

function register_tasks($tasks,$nums){
    <table>    
    <td><input type="textbox" size="50" name="register_description"/> </td></tr>
    <td><input type ="textBox" name="register_num" /> </td>
    <td><input type="submit" name="add_register_tasks" value="Add"/></td></tr>
    </table>
    <?
    if(count($tasks) > 0){
        ?>
        <table>
        <tr><td><b>Registration Item Description</b></td><td><b># Of Available Spots</b></td></tr><br>
        <?
        foreach (array_combine($tasks, $nums) as $task => $task_num){
            ?>
            <tr><td><? echo $task; ?></td><td><? echo $task_num; ?></td>
            <td><input type="submit" name="remove_task" value="Remove"/></td>
            <td><input type="hidden" name="task_name" value="<? echo $task; ?>"/>
            <td><input type="hidden" name="task_num" value="<? echo $task_num; ?>"/></td></tr>

            <?
        }
        ?></table><?
    }

You need to place the form tag inside the loop. Right now what happens is all the records are displayed in a single form and no matter what item you choose, it takes only the last value. Another alternate solution would be to use GET method and pass the number/name as query string.