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>

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>

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.