Page 1 of 1

page/content linking via a switch statement

Posted: Wed Jul 10, 2002 6:35 am
by SirJester
hello, i am relatively new to php and i am having some trouble linking to new pages/statements via a switch statement.

here's my code:

Code: Select all

<?php 

$links = "<a href="code.php?theme=1">Link1</a><br><a href="code.php?theme=2">Link2</a><br><a href="code.php?theme=3">Link3</a><br>";

switch ($theme) &#123;
case 1:
	echo "You are using theme 1<br>";
	echo "$links";
	break;
case 2:
	echo "You are using theme 2<br>";
	echo "$links";
	break;
case 3:
	echo "You are using theme 3<br>";
	echo "$links";
	break;
default:
	echo "You are using the default theme<br>";
	echo "$links";
	break;
&#125;
?>
what i get when i run this as code.php is the default statement plus the 3 links, when i click on say link1 or link 2 or link3 is the page doesn't change to the new content. The address bar show code.php?theme=1 and so on, but the page contents doesn't change :(

At one stage i inserted a line to print out the $theme varible just before the switch statement begins but it was always empty.

I have searched through this board for an answer and from what i have read this code looks right..?

soo... what am i missing?? any help would be much appreciated.

Posted: Wed Jul 10, 2002 6:43 am
by twigletmac

Posted: Wed Jul 10, 2002 6:57 am
by SirJester
thanx for your speedy response :)

that post solved my prob, inn my haste and frustration of my script not working i totally missed that sticky :x

thanx for your help :)