Looping problem with templates
Posted: Fri Nov 14, 2008 12:33 pm
I have some problems figuring out how to solve a template rendering problem with php.
Lets say I have for example in template something like this. I fetch data from db and I need to loop the part between comments for unknown times depending on the data fetched from db. From db eg. each row has three values (label, desc and price).
So what would be the best way to implement this looping with php? Or is there any good ways? The reason why php is not allowed in templates at all is that all of the users who will be editing templates later does not know any php or mysql.
Lets say I have for example in template something like this. I fetch data from db and I need to loop the part between comments for unknown times depending on the data fetched from db. From db eg. each row has three values (label, desc and price).
Code: Select all
<head><title>[:title:]</title></head><body><h1>[:heading:]</h1><table><!-- part that will be looped starts --><tr> <td> [:label:] - [:desc:] - [:price:]</br> </td></tr><!-- looped part ends --></table></body></html>