jimmyborofan Posted September 20, 2008 Share Posted September 20, 2008 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 https://forums.phpfreaks.com/topic/125098-nearly-there-but-not-quite-switch-and-case-functions/ Share on other sites More sharing options...
Stooney Posted September 20, 2008 Share Posted September 20, 2008 All looks good except this: $country = $_GET['$country']; use this: $country=$_GET['country']; Also change this: <?=$capital?> to: <?php echo $capital; ?> I'm assuming that's where you wanted it output at. Also, do not use short tags. Link to comment https://forums.phpfreaks.com/topic/125098-nearly-there-but-not-quite-switch-and-case-functions/#findComment-646513 Share on other sites More sharing options...
PFMaBiSmAd Posted September 20, 2008 Share Posted September 20, 2008 Because the links have a $ in $country, $_GET['$country'] would be correct (but confusing.) The $ in the link would need to be removed as well to work with $_GET['country'] Link to comment https://forums.phpfreaks.com/topic/125098-nearly-there-but-not-quite-switch-and-case-functions/#findComment-646518 Share on other sites More sharing options...
jimmyborofan Posted September 20, 2008 Author Share Posted September 20, 2008 You diamonds! Thank you its now working and I can finally get on with the rest of the stuff that I need to do! (dont worry though... No doubt when my next assignment comes along I will be back here!) Thanks peeps Jimmy Link to comment https://forums.phpfreaks.com/topic/125098-nearly-there-but-not-quite-switch-and-case-functions/#findComment-646524 Share on other sites More sharing options...
chronister Posted September 20, 2008 Share Posted September 20, 2008 <?=$capital?> You should get in the habit of writing it as <?php echo This is valid shorthand for now, but if short_open_tags is turned off on a server, then this functionality will break. Link to comment https://forums.phpfreaks.com/topic/125098-nearly-there-but-not-quite-switch-and-case-functions/#findComment-646526 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.