For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > May 2004 > AW: [SMARTY] How can one create a table dynamically with Smarty ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author AW: [SMARTY] How can one create a table dynamically with Smarty ?
Ben

2004-05-04, 4:05 pm

You mean the code below would produce 2 Columns?

To span a table with my framework i just used this code
in my output-template

<table>
{section name=3Dn loop=3D$data}
<tr>{foreach item=3Dval from=3D$data[n]} =20
<td style=3D"background-color:#{if
($smarty.section.n.iteration%2)=3D=3D0}D9D9D9{else}FFFFFF{/if};">{if
!$val}&nbsp;{else}{$val}{/if}</td>
{/foreach}
</tr>
{/section}
</table>


in this case $data is an 2dimensional array, as you will get it when
reading
some rows from a database. each row is an array stored as element of
another
one so here.
The 1st dimension i walk through with the section, the second one with
the foreach, because its associative.

hth
Ben


-----Urspr=FCngliche Nachricht-----
Von: Pete [mailto:webmaster@dentona.de]=20
Gesendet: Freitag, 30. April 2004 15:50
An: smarty-general@lists.php.net
Betreff: Re: [SMARTY] How can one create a table dynamically with Smarty
?


Hi Gabriel,

thank you very much for the reply.
Unfortunately that doesn't help at all.
The problem is that a multi column table is needed.
The code below will only produce a table with one column.

<table>
{section loop=3D$data name=3Di}
<tr><td>{$data[i].image}</td><td>{$data[i].description}</td></tr>
{/section}
</table>

Thx anyway and have a nice wend!!

Regards Pete

--=20
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


---
________________________________________
__________________
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28.04.2004
=20

---
________________________________________
__________________
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28.04.2004
=20
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com