Why not just do all of it in SQL?  Or you can iterate everything into an
array, before you push it to the presentation layer.

...

$data = array();
while($row = $result->doSelect($criteria)){
  array_push($data, array( '3-shop-sum' => $row['1st-shop'], '2nd-shop' =>
$row['2nd-shop'], '3rd-shop' => $row['3rd-shop'], '3-shop-sum' =>
$row['3-shop-sum'], 'previous-day' => $previous);
  $previous = $row['3-shop-sum'];
}

$template->set('list', $data);

...

On Sun, Mar 23, 2008 at 6:02 PM, Krzysztof Zaleski <[EMAIL PROTECTED]>
wrote:

>
> Hi,
>
> Let's assume I have a table (generated from DB) with 3 columns with daily
> receipts from three shops. Fourth column is a sum of all three values (sum
> is calculated by SQL query). Now, I would like to add next column showing
> the difference between the sum of current day, and the value from previous
> day. I tried using tal:define in various ways, but I either get the message
> that some variable is redefined twice, or some variable definition is
> missing. From my tests it seems that I cannot accomplish this task with
> tal:define. If I could do something like tal:php :-) it would be perfect.
> The whole idea is rather simple, but I don't know how to store previous
> value from one row iteration to another. Any ideas?
>
> Rgrds,
> Krzysztof
>
> _______________________________________________
> PHPTAL mailing list
> PHPTAL@lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal
>
>
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to