Page 1 of 1

If statements within If statements

Posted: Sun Apr 22, 2007 8:07 pm
by fatalkaiser
Jcart | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


How do i do it?

What im trying to do looks something like this

Code: Select all

<?php 
if ($variable == "blah") 
(
	if ($variable2 == "blahblah")
	{
	$a = 1;
	$b = 2;
	$c = 3;
	};
	
	else 
	{
	$a = 2;
	$b = 3;
	$c = 4;
	};
)
else
                {
	echo "blah"; 
	};
?>

Can someone give me the correct coding for this?


Jcart | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Apr 22, 2007 8:19 pm
by John Cartwright
Your using normal brackets () instead of curly {} in the first if statement.

Posted: Sun Apr 22, 2007 8:47 pm
by fatalkaiser
Thanx a lot!
That was the last little bug in my script and now it works perfectly. You guys are great here :) Keep up the good work

Posted: Sun Apr 22, 2007 9:51 pm
by the_last_tamurai
delete the semi-colons ';' after the curly brackets '}'

Posted: Sun Apr 22, 2007 9:53 pm
by John Cartwright
the_last_tamurai wrote:delete the semi-colons ';' after the curly brackets '}'
Those are actually valid :wink:

Posted: Sun Apr 22, 2007 9:57 pm
by the_last_tamurai
thanx , I didnt know that, but is it a recommended coding style??? just a question :?:

Posted: Sun Apr 22, 2007 10:00 pm
by John Cartwright
Personal preference.. although I rarely see it being used. This is probably the 2nd time I've seen someone use it.