Need help with PHP Switch Case problem
Go to solution
Solved by LukeTim,
nope still doesn't work dude this is the code
<?php function menu($day, $meal){ switch ($day) { case 'Saturday': switch($meal) { case "B" { echo "MENU for Saturday: Breakfast"; break; } case "L": { echo "MENU for Saturday: Lunch"; break; } case "D" { echo "MENU for Saturday: Dinner"; break; } default: { echo "<p class='Paragraph'>Not a valid MENU for Saturday</p>"; break; } } break; case 'Sunday': switch($meal) { case "B": { echo "MENU for Sunday: Breakfast"; break; } case "L": { echo "MENU for Sunday: Lunch"; break; } case "D": { echo "MENU for Sunday: Dinner"; break; } default: { echo "<p class='Paragraph'>Not a valid MENU for Saturday</p>"; break; } } break; default: echo "No MENU"; break; }}/*end of function*/ // Get data from the form$day = 'Sunday';//$_POST['day'];$meal = 'B';//$_POST['meal'];// Call functionmenu($day, $meal); //These should not be strings anyway?>
There are some missing colons in the first switch on $meal.
Seriously, what happens when you try to run it? I could see a problem here this time but it's not easy to identify the problem when you don't tell me what php is saying about the script.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now