Smarty Loop Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Smarty Loop Question

Post 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: **
Post Reply