Sections Question
| From: | Oleg Krogius | Date: | Fri, 18 Oct 2002 22:41:22 +0000 |
| Subject: | Sections Question | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6193@lists.php.net to get a copy of this message | ||
Hi,
I have my PHP code to do this prior to displaying the template:
$template->assign('items_ar',$result->GetArray(25));
Basically that creates a multidimensional array. For example, let's say
I have a database with 4 columns - id, date, blurb, content. Therefore
for example:
$md_array = $result->GetArray(25);
echo $md_array[0]['id]; //echoes id of the first item
echo $md_array[0]['date']; //echoes date of the first item
echo $md_array[0]['blurb']; //echoes date of the first item
echo $md_array[0]['content']; //echoes date of the first item
echo $md_array[1]['id']; //echoes id of the second item
echo $md_array[1]['date']; //echoes date of the second item
echo $md_array[1]['blurb']; //echoes blurb of the second item
echo $md_array[1]['content']; //echoes content of the second
item
//etc
My question is how would I set up a section in a template to loop
through this multidimensional array. Here's what I tried, but it doesn't
seem to work (gives undefined index errors).
{section name=items loop=$items_ar}
<a href="items/show/{$items_ar[items].id}">
{$items_ar[items].name}</a> - {$items_ar[items].date} -
{$items_ar[items].blurb}<br />
{sectionelse}
No records found.
{/section}
Any idea what I'm doing wrong and how I should do this? Thanks in
advance.
Sincerely,
Oleg Krogius