Jump to content

[SOLVED] else if


jakebur01

Recommended Posts

Is there a limit on how many else if statement you can use?

 

I am getting a PHP Parse error: parse error, unexpected T_CLASS about the fifth one down.

 

if($productform == 'Shinform')
$productselect = Shin;

elseif($productform == 'Littleform')
$productselect = Little;

elseif($productform == 'Manform')
$productselect = Man;

elseif($productform == 'Smithform')
$productselect = Smith;

elseif ($productform == 'Classform')
$productselect = Class;

elseif($productform == 'OregonOform')
$productselect = OregonO;

elseif($productform == 'OregonFform')
$productselect = OregonF;

elseif($productform == 'Troyform')
$productselect = Troy;

elseif($productform == 'Whiteform')
$productselect = White;

elseif($productform == 'Trenchform')
$productselect = Trench;

else
echo $URL="http://www.mysite.com/nodealerselect.html";
header ("Location: $URL");

Link to comment
https://forums.phpfreaks.com/topic/48515-solved-else-if/
Share on other sites

Easier and neater option would be to use Swith/case:
[code]
switch($productform){

case "Shinform":
$productselect = "Shin";
break;

case "Littleform":
$productselect = "Little";
break;

default:
echo $URL="http://www.mysite.com/nodealerselect.html";
header ("Location: $URL");
break;


}
etc etc

 

If others find the need to correct me please do so, have not used switch case in a while...[/code]

Link to comment
https://forums.phpfreaks.com/topic/48515-solved-else-if/#findComment-237341
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.