Jump to content

Nearly there but.... not quite! switch and Case functions


jimmyborofan

Recommended Posts

right then here goes...

 

After the help I had earlier I have begun to try to pass a value across from one page to another dependiong upon the value, the page displays one thing or another ( I know this is simple stuff but seriously

 

<------------------------NEWBIE!!!!!!!!!!!!!!!!!!!!!

 

see what I mean...)

 

 

okay the code I have so far has a page with four links that show countries

 

when sent to the second page, the page should display the capital.

 

Here is the code:

 

link.html

<html>
<body>
<p><a href="contact.php?$country=UK">The United Kingdom</a></p>

<p> <a href="contact.php?$country=US">The United States</a></p>

<p><a href="contact.php?$country=FR">France</a></p>

<p> <a href="contact.php">Not sure...</a></p>

</body>
</html>

 

 

and this is the page that the values are sent too:

 

capitals.php:



<html>
<body>
<?php
$country = $_GET['$country'];
switch ($country)
{
case 'UK':
$capital = 'London';
break;
case 'US':
$capital = 'Washington';
break;

case 'FR':
$capital = 'Paris';
break;
default:
$capital = 'Unknown';
break;
}
?>

<?=$capital?>
</body>
</html>

 

As other members may see I am trying to transpose from what I know of asp across to php, now absolutley nothing happens!

 

Please could somebody give me some direction or just plainly point out where I have gone wroing then give me a slap on the back of the head!

 

lol

 

Jimmy

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.