Page 1 of 1

Jump to Else

Posted: Tue May 24, 2011 1:33 pm
by unemployment
I have a page that has a continue button. If the user presses continue, I want to run the stuff in the else part of the if. Is this possible?
<?php

if (something)
{
	//do something here
	<input type="submit" value="continue button" />
}
else
{
	//if the continue button was press go down to the else part of this if
}

?>

Re: Jump to Else

Posted: Tue May 24, 2011 1:36 pm
by ashwood
Why would you want to do that?

if your using a if you want
if(something)
{

 works
}
ELSE
{

the else is for if the something fails to do what you want..

}
so why would you do that?

Re: Jump to Else

Posted: Tue May 24, 2011 1:56 pm
by jacek
if (isset($_GET['continue'])
{
    //do something here
}
else
{
    ?>
    <form action="" method="get">
        <p>
            <input tyoe="hidden" name="continue" value="1" />
            <input type="submit" value="continue button" />
        </p>
    </form>
}
this is just basic logic...

Re: Jump to Else

Posted: Tue May 24, 2011 2:08 pm
by unemployment
jacek wrote:
if (isset($_GET['continue'])
{
    //do something here
}
else
{
    ?>
    <form action="" method="get">
        <p>
            <input tyoe="hidden" name="continue" value="1" />
            <input type="submit" value="continue button" />
        </p>
    </form>
}
this is just basic logic...
Basically, I am trying to say... if company names match... show suggested companies, but if you press continue because those companies don't match the one you are creating, go to the next step and finish creating your company.

Re: Jump to Else

Posted: Tue May 24, 2011 2:29 pm
by jacek
unemployment wrote:Basically, I am trying to say... if company names match... show suggested companies, but if you press continue because those companies don't match the one you are creating, go to the next step and finish creating your company.
Cool... so ... what's that problem now ?

Re: Jump to Else

Posted: Tue May 24, 2011 2:53 pm
by unemployment
Cool... so ... what's that problem now ?
The problem is that I have it set up like...
if (company names match the one you typed)
{
    // show suggested companies and join one or press continue
     <input type="submit" value="continue" />
} 
else
{
   // those companies don't match the one you are creating or you pressed continue
   //finish creating your company.
},

Re: Jump to Else

Posted: Tue May 24, 2011 3:10 pm
by jacek
okay...

so what is preventing you from using the example above to create the correct code ?

Re: Jump to Else

Posted: Sun May 29, 2011 7:55 pm
by martijn1
You can use the switch() method..

http://w3schools.com/php/php_switch.asp

Re: Jump to Else

Posted: Sun May 29, 2011 7:58 pm
by bowersbros
switch is basically for use instead of a big list of else ifs.