Page 1 of 1

Smarty Loop Question

Posted: Mon Apr 25, 2005 10:07 am
by neophyte
Okay I've got a db call that retrieves an associative array:

Code: Select all

$articles = $db->GetAssoc($sql); 
print_r($articles);
Outputs this:

Code: Select all

Array
(
    ї158] => Array
        (
            їarticle_id] => 158
            ї0] => This string
            їarticle_title] => This String
            ї1] => This String
            їarticle_short] => Another String
            ї2] => Some Picture
            їarticle_picture] => Some Picture
            ї3] => 1
            їarticle_active] => 1
        )  
ї157] => Array
        (
            їarticle_id] => 158
            ї0] => This string
            їarticle_title] => This String
            ї1] => This String
            їarticle_short] => Another String
            ї2] => Some Picture
            їarticle_picture] => Some Picture
            ї3] => 1
            їarticle_active] => 1
        )

}
Assigned to smarty like this:

Code: Select all

$smarty->assign('articles', $articles);
Template implementation:

Code: Select all

{section name=i loop=$articles}
<p>{$articlesїi].article_id}
{$articlesїi].article_title}</p>

{/section}
I don't get any output with this at all. Does anybody know how to correctly loop through the above array using Smarty?


**This post previously listed under general discussion -- Sorry folks, it must be Monday :oops: **