[Solved] If statement query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

[Solved] If statement query

Post 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
Last edited by Addos on Sun Apr 02, 2006 5:31 am, edited 1 time in total.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post 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
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Post by Addos »

thanks you for pointing this silly error out.
Best wishes
B
Post Reply