If-clause in a foreach loop at Smarty-template-system

desire121

New Member
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\[code\] $get_genre = mysql_escape_string($_GET['genre']); $smarty->assign('get_genre',$get_genre);\[/code\]The Smarty-template to generate the options of the dropdown is\[code\]{foreach item=genre from=$genres}<option {if $get_genre == $genre }selected="yes"{/if}>{$genre}</option>\[/code\]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.
 
Back
Top