Categories > TinyButStrong general >

how to use 'if then else' to make a comlicatied logical judgement?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: winks
Date: 2009-08-17
Time: 06:07

how to use 'if then else' to make a comlicatied logical judgement?

hi,
following is my problem:

html   my.htm
-------------------------------------------------------------------
<table>
<tr><td>
[blk.stat;block=tr;if [val]=='ok';then [rece.rest;p1=[blk.indexno;block=tr];if [val]+-100;then '<img src="topay.gif"/>';else '<img src="payok.gif"/>'];else '']
</td></tr>
</table>


php   my.php
--------------------------------------------------------------------
<?php
include('tbs.php');
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('my.htm') ;

$BLKSQL = 'select stat,indexno from cont';
$TBS->MergeBlock('blk','mysql',$BLKSQL);
$RECESQL = 'select sum(rest) from rece where contindexno="%p1%" group by contindexno';
$TBS->MergeBlock('rece','mysql',$RECESQL);

$TBS->Show();
?>


but,it doesn't work as my thought.
the second [val] in my.htm should be a number of payment, but now the value of two [val] are the same (both are the stat from the cont table)...
what's wrong with my code? or shouldn't i code like that?
help me ,thax a lot,everyone~~
By: Skrol29
Date: 2009-08-17
Time: 14:05

Re: how to use 'if then else' to make a comlicatied logical judgement?

Hi Winks,

Your template is strange, but what is the result you're trying to have?
And why to you use a sub-block just for calculating a SUM() ? Can't you have this with a sub query?
By: sheepy
Date: 2009-08-19
Time: 04:52

Re: how to use 'if then else' to make a comlicatied logical judgement?

I see that there are two level of blocks.  If you want to merge the second level independently, you need to use the first block merge to gives each merged tr's inner block a unique name, and then merge those blocks in a loop.

When in doubt, check examples. :)