smarty发布来自while / section循环的数据

I have a smarty page that loops through a table in the database. For each row, I have a submit button. If I click the submit button it should only post back the data for that row. The problem is it posts back the very last row each time. It cant distinguish the difference per row. Any ideas?

Heres my code:

    <!--{section name=ct  loop=$data}-->
    <tr>
    <td><center><!--{$data[ct].id}--></center></td>
    <td><!--{$data[ct].name}--></td>
    <td><!--{$data[ct].cars}--></td>
    <td><!--{assign var=key value=$data[ct].id}-->       
    <input type="hidden"  name="id" value="<!--{$key}-->">
    <a href="javascript:;" 
onclick="javascript:erase();return false;">DELETE</a>
    </tr>
    <!--{/section}-->

As you have multiple, input field with same name, it always overwrite the previous one, So you are always getting the value for last one.

Solution :

<a href="server_page.php?id={$key}" onclick="javascript:erase();">DELETE</a>

Get this id in your server page, using $id= $_GET['id']; and do delete in your database.