tags:

views:

29

answers:

1

hello everyone,

I got a question. i have tha following foreach loop:

{foreach from=$films item=film key=id}
                <tr>
                    <td>
                        {$film.filmtitel}
                    </td>
                    <td>
                        {$film.zaaltitel}
                    </td>
                    <td>
                        plaats {$film.stoeltjes}
                    </td>
                    <td>
                        {$film.dag}
                    </td>
                    <td>
                        {$film.tijdstip}
                    </td>
                    <td>
                        5€
                    </td>
                    <td>
                        <a href="?page=winkelwagentje&amp;action=verwijder&amp;id={$smarty.forach.id.index}">
                        <img src="images/verwijderButton.png"  alt="verwijderButton" title="verwijderButton"/></a>
                    </td>
                </tr>
                {/foreach}

these represent various items. now when its displayedin the browser the link gives me the url, ending with:

id=0 then the next is id=1 and so on.

When i remove 1 of these items through a button, the id's automaticly get rearranged so the index starts back with 0, then 1 and so on. What i would like to have is that if for instance i remove item with id=1 and the page gets refreshed, the id should remain deleted.

So the urls would look like:

id=0 id=2 id=3

anyone know if this is possible?

A: 

I understand your problem. You could rely on the keys of the array, but in this case you should populate the array in the same order and with the same id. It seems for me that this is a result set from a database table. It would be much easier to rely on an id of the database table which has unique values.

btw. you have a typo in your example code (...id={$smarty.forach...)

Zsolti