views:

33

answers:

1

I use Smarty as a template system in a script of mine.

There is a page with drop-down-boxes (to select a music genre) and the form is reloaded with an on-change event. The value of the drop-down-boxes are transfered via GET.

The drop-down-boxes should have the value selected before.

The PHP-Code concerning the GET code is

    $get_genre = mysql_escape_string($_GET['genre']);
    $smarty->assign('get_genre',$get_genre);

The Smarty-template to generate the options of the dropdown is

{foreach item=genre from=$genres}<option {if $get_genre == $genre }selected="yes"{/if}>{$genre}</option>

The drop-down-values ($genres) are listed correctly and the $get_genre is also there, if you put it into the template. So everything for itself works.

But the if-clause doesn't work, so the box is not selected if a genre is selected before. :-(

I searched for a solution of that problem several hours, but didn't found anything.