Jump to content


Photo

Including a switch in a switch


  • Please log in to reply
1 reply to this topic

#1 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 17 April 2006 - 06:21 PM

im making a thing kinda like when you dial a phone to a company (I.E press 1 for english, 2 for french.....then when you hit 1 it comes up hit 1 to talk to sales...hit 2 to talk to customer support...etc..etc)you know what i mean.....well in order to do this i used switch... but it doesnt seem to work...because it requires a switch to be inside a switch... heres the page....
[a href=\"http://www.mattswebpage.com/other%20tests/phoneline%20idea.php\" target=\"_blank\"]Phone line idea[/a]

and heres the script(no switches inside switches yet)
<html>
<form name="p1" method="GET">
<b>Step 1:</b><br>Press 2 to go to mattswebpage<br>
Press 1 to go to splatmen<br>
Press 3 to go to LIFD<br>
<input type="text" name="ppp" size="2" value="0">
<input type="submit" name="submit1" value="Next">
</form>
<?php
if(isset($_GET['submit1'])){
$ppp=$_GET['ppp'];
switch($ppp){
case '0':
echo "Please Enter a number from 1-3!";
break;
case '1':
echo "<b>Step 2:</b><br>Forums Press 1<br>
Home Press 2<br>
chat room Press 3<br>
<form name='p2' method='get'><input type='text' name='pp2' value='0' size='2'><input type='submit' name='submit2' value='Next'></form>";
$pp2=$_GET['pp2'];
break;
case '2':
echo "<b>Step 2:</b><br>Forums Press 1<br>
Home Press 2<br>
chat room Press 3<br>
contact Press 4<br>
<form name='d3' method='post'><input type='text' name='pp3' value='0' size='2'><input type='submit' name='submit3' value='Next'></form>";
break;
case '3':
echo "this would look something like the others.....";
break;
case '4':
echo "this isnt a valid number";
break;
}
}    
?>


"Syntax error" .. WHERE THE **** IS IT?!

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 17 April 2006 - 09:40 PM

Switch statements can be inbeded in side each other:
switch($foo)
{
    clase 1:
        switch($foobar)
        {
            case 1:

        }
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users