|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
GeXus Smarty Rookie
Joined: 16 Aug 2006 Posts: 28
|
Posted: Sun Jan 28, 2007 7:18 pm Post subject: Multidementional arrays using section and sub loops |
|
|
I'm trying to display categories and then the sub categories below it. I've tried everything! (i think).. I started using foreach and that worked, but I wanted to display everything in columns and couldnt seem to get it working, now i've gone to using section and it seems that if i can use section and then a nested section, that it would work perfect.
this is what I currently have.
These are my queries:
Code: |
$db->sql_query('select name as cat_name, category_id as cat_id from categories order by cat_name asc');
while ($row = $db->fetch_array()){
$cats[] = $row;
}
$smarty->assign('cats', $cats);
$db->sql_query('select name as sub_name, sub_category_id as sub_cat_id from sub_categories order by sub_cat_id asc');
while ($row = $db->fetch_array()){
$subcat[] = $row;
}
|
and this is my template
Code: |
{section name=tr loop=$cats step=$cols}
<tr>
{section name=td start=$smarty.section.tr.index loop=$smarty.section.tr.index+$cols}
<td>
<B>{$cats[td].cat_name}</B>
{section name=subcats loop=$subcats}
{$subcats[td][subcats]}
{/section}
</td>
{/section}
</tr>
{/section}
|
Needless to say, it is not working. There are no sub categories being shown, and I don't even know if it would be assigned properly.
I have two tables, one with categories and one with sub categories. If needbe, I could restructure this into one table with a related category ID, but I would rather not.
If someone could help with this it would be huge, i'm completely lost at this point.
Thank You! |
|
Back to top |
|
GeXus Smarty Rookie
Joined: 16 Aug 2006 Posts: 28
|
Posted: Mon Jan 29, 2007 2:35 am Post subject: |
|
|
Still trying to figure this out if anyone has any ideas... thanks! |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|