Forum Moderators: coopster

Message Too Old, No Replies

PHP ifs, elses and elsifs....

         

omoutop

10:31 am on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi to all again..hope u had a great weekend....
my problem is related to an if-elseif-else script where I would like to present some inormation according to flags...here is my code:

if ($FlagDistance='Y' ¦¦ $FlagDD='Y')
{
?>
<strong><? echo $name?></strong> is located in <? echo $town?>, <? echo $Beach?> Km from the Beach, <? echo $Center?> Km from the Center, <? echo $Port?> Km from the Port and <? echo $Airport?> Km from the Airport of <? echo $location?>.
<br>
<strong>Addiotional Information:</strong>
<br>
<?
echo $distancesdescr;
}
else
{
if ($FlagDistance ='Y')
{
?>
<strong><? echo $name?></strong> is located in <? echo $town?>, <? echo $Beach?> Km from the Beach, <? echo $Center?> Km from the Center, <? echo $Port?> Km from the Port and <? echo $Airport?> Km from the Airport of <? echo $location?>.
<?
}
else
{
echo $distancesdescr;
}
}
?>
the idea is that if if flagdistance and flagDD are both Y then display the following...if not ...check if flag distance is Y and if not display only the $distancesdescr;....
the current script always displays the "$FlagDistance='Y' ¦¦ $FlagDD='Y'" part even whenboth rules dont apply,,
ANY IDEAS?

dreamcatcher

10:40 am on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi omoutop,

You need to use comparison operators.

if ($FlagDistance='Y' ¦¦ $FlagDD='Y')

should be:

if ($FlagDistance=='Y' ¦¦ $FlagDD=='Y')

Let us know if that helps.

dc

omoutop

10:44 am on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thx very much Dreamcather...
the code I needed is this:

if ($FlagDistance == 'Y'&& $FlagDD == 'Y')

u helped....

dreamcatcher

12:21 pm on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No problem. :)