FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Php Switch Case
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Php Switch Case [message #169372] Wed, 08 September 2010 18:54 Go to previous message
jfcby is currently offline  jfcby
Messages: 2
Registered: September 2010
Karma:
Junior Member
I'm trying to get this php script to either include a web page,
redirect to another webpage, or echo text. I have this page in the
main www folder on the server.

My problem is if I type the webpage address like so www.ebooktaught.com/prodtest.php
then it displays the first switch case instead of the default.

How can I get the following script to:

1. After I type in www.ebooktaught.com/prodtest.php it will display
the default echo?
2. How can I get the script to work if I type in
www.ebooktaught.com/prodtest.php?pg=pd&nb=2 for it to display the
second switch case?


<?php
	$gpg = $_GET["pg"];
	$gnb = $_GET["nb"];
	Switch ($gpg){

		Case $gpg == 'pd' && $gnb == 1:
			echo "Product Page = " . $_GET['pg'] . " & Product Page # = " .
$_GET['nb'];
		break;
		Case $gpg == 'pd' && $gnb == 2:
			echo "Product Page = " . $_GET['pg'] . " & Product Page # = " .
$_GET['nb'];
		break;

		Case $gpg == 'sp' && $gnb == 1:
			echo "Product Page = " . $_GET['pg'] . " & Product Page # = " .
$_GET['nb'];
		break;
		Case $gpg == 'sp' && $gnb == 2:
			echo "Product Page = " . $_GET['pg'] . " & Product Page # = " .
$_GET['nb'];
		break;

		default:
			echo "Default";
	}
?>


Thank you for your help,
jfcby
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Another heredoc question
Next Topic: Downloading files, without internet renumbering...
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 19:44:48 GMT 2024

Total time taken to generate the page: 0.04430 seconds