From: <jiva@devware.com>
So, I want to generate a table using DTML and data from a database. I want each row returned from the database to go into it's own html cell, and I want to have say, 4 html columns across the page before starting a new row. So like:
<table> <tr> <td> Row 1 from DB </td> <td> row 2 from db </td> <td> row 3 from db </td> <td> row 4 from db </td> </tr> <tr> <td> row 5 from db </td> ...
How can I do this? Is there some kind of dtml-if I can wrap around the </tr><tr> to only make it show every 4th row?
You could use the count- variable to find the rows where you need to insert the <tr>'s. If the returned column name is 'value', use code like this (untested): <table><tr> <dtml-in db_query> <dtml-if "_['count-value'] % 4 == 0"></tr><tr></dtml-if> <td><dtml-var value></td> </dtml-in> </tr></table> Now, I could be wrong and count-value is 1 based in stead of 0 based. In fact, I believe it is, it would make sense anyway. Then you'd adjust the logic slightly, something like (_['count-value'] - 1) % 4. -- Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ | The Open Source Web Application Server ---------------------------------------------