Page 1 of 1
add a constant to a formula
Posted: Tue Sep 29, 2009 10:50 pm
by podarum
I'm trying to create a new field call it $N, and I want to give it a value of 1 where ever there is an image in the formual..take a look..
Code: Select all
<?php if(($OpenDT=="") or ($CurrentDT=="")) {echo "";} elseif($Months<=6) {echo '<img src="images/check.png" width="25" height="20">';} $N=1 elseif($Months<=12) {echo "";} else {echo "";}?><TD align=center bordercolor='#f6faff'>
So when $Months <=6, I want the image plus the field $N to equal =1 .. any idea .. thanks
Re: add a constant to a formula
Posted: Tue Sep 29, 2009 11:07 pm
by iamngk
Your $N is not placed in IF control structure more over it is placed in wrong place. Also for better handling of variable, you have to initiate the $N variable. Please try the below code.
Code: Select all
<?php $N=0;
if(($OpenDT=="") or ($CurrentDT=="")) {echo "";} elseif($Months<=6) {echo '<img src="images/check.png" width="25" height="20">'; $N=1; } elseif($Months<=12) {echo "";} else {echo "";}?><TD align=center bordercolor='#f6faff'>
Re: add a constant to a formula
Posted: Tue Sep 29, 2009 11:13 pm
by podarum
You da man.... thanks... it worked perfectly...
Re: add a constant to a formula
Posted: Wed Sep 30, 2009 10:22 am
by podarum
Ok, I'm back with more...
Now that I have $N=1, for everytime the $N gets a 1 (see the second <?php ($Age<=6) also assigns the $N another 1 for a total of 2 now and so forth... How can I count them ?
Code: Select all
<?php $N=0;
if(($OpenDT=="") or ($CurrentDT=="")) {echo "";} elseif($Months<=6) {echo '<img src="images/check.png" width="25" height="20">'; $N=1; } elseif($Months<=12) {echo "";} else {echo "";}?><TD align=center bordercolor='#f6faff'>
<?php $N=0;
if(($OpenDT=="") or ($CurrentDT=="")) {echo "";} elseif($Age<=6) {echo '<img src="images/check.png" width="25" height="20">'; $N=1; } elseif($Age<=12) {echo "";} else {echo "";}?><TD align=center bordercolor='#f6faff'>