I think I got the solution to your problem. Try this kind of template:

<table>
<tr tal:repeat="datarow data">
<td tal:content="repeat/datarow/index">row number</td>
<td tal:content="datarow/0">row[0]</td>
<td tal:content="datarow/1">row[1]</td>
<td tal:content="datarow/2">row[2]</td>
<td tal:content="datarow/3">sum</td>
<tal:block condition="repeat/datarow/start">
<td>---</td>
<td>---</td>
</tal:block>
<tal:block condition="not: repeat/datarow/start">
<td tal:content="php: data[repeat.datarow.index-1][3]">prev_sum</td>
<td tal:content="php: datarow[3] - data[repeat.datarow.index-1][3]">delta</td>
</tal:block>
</tr>
</table>

I tried to write it in a self-explaining way.

P.S.:I assumed the data from DB is in this form:
$data = array(
        0 => array('1','2','2','5'),
        1 => array('3','4','5','12'),
        2 => array('0','2','1','3'),
);
If I'm wrong, you should at least get the idea of the solution.

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to