PHP / Smarty Tricks - Avoid looping for more than one loop for select query
The best way is we can use "IN_ARRAY" method, Here is the basic sample i have given,
{assign var = "exp" value = ","|explode:$catid}
{section name=k loop=$blogcat}
<option {if in_array($blogcat[k].CAT_ID, $exp)} selected="selected" {/if} value=" {$blogcat[k].CAT_ID}" >{$blogcat[k].CAT_NAME}
</option>
{/section}
Comments
Post a Comment