Jump to Else

Ask about a PHP problem here.
Post Reply
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Jump to Else

Post 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
}

?>
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

Re: Jump to Else

Post 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?
I would put a signature.. BUT, i don't have the time.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Jump to Else

Post 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...
Image
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Re: Jump to Else

Post 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.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Jump to Else

Post 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 ?
Image
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Re: Jump to Else

Post 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.
},
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Jump to Else

Post by jacek »

okay...

so what is preventing you from using the example above to create the correct code ?
Image
martijn1
Posts: 8
Joined: Mon May 16, 2011 6:48 pm

Re: Jump to Else

Post by martijn1 »

You can use the switch() method..

http://w3schools.com/php/php_switch.asp
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: Jump to Else

Post by bowersbros »

switch is basically for use instead of a big list of else ifs.
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Post Reply