Page 1 of 1

[Solved] If statement query

Posted: Sun Apr 02, 2006 4:08 am
by Addos
Hi,
Can anyone tell me what I’m doing wrong with this bit of code? I need to run an if statement to check if the numeric value is either 29 or 30 but I keep getting various errors no matter what I try.

This is my latest attempt

Code: Select all

<? if ($productId == 29) { ?>
	onclick="newWindow()">
      <?}else{
   if ($productId == 30 ) { ?>
	onclick="newWindow()">
     <? } else {'>';}?>
Thanks very much
B

Posted: Sun Apr 02, 2006 5:18 am
by dibyendrah
you're missing the last bracket for else.

must look like

Code: Select all

<? if ($productId == 29) { ?>
    onclick="newWindow()">
      <?}else{
   if ($productId == 30 ) { ?>
    onclick="newWindow()">
     <? } else {'>';}}?> 
 ?>

I think you're thinking to print '>' rather than just '>'. If yes the code will be

Code: Select all

else  { print '>'; }
Dibyendra

Posted: Sun Apr 02, 2006 5:31 am
by Addos
thanks you for pointing this silly error out.
Best wishes
B