Jump to content

Need Help with my code, It will not execute.


Recommended Posts

Can someone please help me with my code. It will not execute.

 

<html>
<head>
<title>Favorite Original Six Hockey Team</title>
</head>
<body>
<h1>Original Six </h1>
<?php
$t=date("H");
if ($t<"10")
{
echo "Good morning!";
}
else if ($t<"20")
{
echo "Good afternoon!";
}
else
{
echo "Good evening!";
}
?> <br> <br>

<?php
$favhockeyteam="blackhawks";
switch ($favhockeyteam)
{
case "blackhawks":
echo "Your favorite hockey team is blackhawks!";
break;
case "redwings":
echo "Your favorite hockey team is redwings!";
break;
case "bruins":
echo "Your favorite hockey team is bruins!";
break;
case "canadians":
echo "Your favorite hockey team is canadians!";
break;
case "maple leafs":
echo "Your favorite hockey team is maple leafs!";
break;
case "rangers":
echo "Your favorite hockey team is rangers!";
break;
default:
echo "Your favorite color is neither red, blue, or green!";
}
?> <br> <br>

</body>
</html>

Link to comment
Share on other sites

Seems to be working fine for me...

http://codetut.com/projects/switch.php

I am guessing you are trying to pass in a variable so it switches cases?

if so I added some code for you

you can try it like this

http://codetut.com/projects/switch.php?team=redwings

 

here is the code now

<html>
<head>
    <title>Favorite Original Six Hockey Team</title>
</head>
<body>
<h1>Original Six </h1>
<?php
$t = date("H");

if ($t < "10")
{
    echo "Good morning!";
}
else if ($t<"20")
{
    echo "Good afternoon!";
}
else
{
    echo "Good evening!";
}
?> <br> <br>

<?php
$favhockeyteam = isset($_GET['team']) ? $_GET['team'] : "";
switch ($favhockeyteam)
{
    case "blackhawks":
        echo "Your favorite hockey team is blackhawks!";
        break;
    case "redwings":
        echo "Your favorite hockey team is redwings!";
        break;
    case "bruins":
        echo "Your favorite hockey team is bruins!";
        break;
    case "canadians":
        echo "Your favorite hockey team is canadians!";
        break;
    case "maple leafs":
        echo "Your favorite hockey team is maple leafs!";
        break;
    case "rangers":
        echo "Your favorite hockey team is rangers!";
        break;
    default:
        echo "Your favorite color is neither red, blue, or green!";

}
?> <br> <br>

</body>
</html>
Edited by chriscloyd
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.