...

View Full Version : useing switch statement



Crash1hd
09-19-2005, 11:06 PM
I am very new to php and was wondering how do I get the users addressbar info into the switch statement

see below where $x is http://www.site.com?name=$x so if I had Http://www.site.com?name=1 then case 1 would run


<?php
switch ($x)
{
case 1:
echo "Number 1";
break;
case 2:
echo "Number 2";
break;
case 3:
echo "Number 3";
break;
default:
echo "No number between 1 and 3";
}
?>

raf
09-19-2005, 11:26 PM
i suppose yu're looking for


<?php
switch ($_GET['name']){
case 1:
echo "Number 1";
break;
case 2:
echo "Number 2";
break;
case 3:
echo "Number 3";
break;
default:
echo "No number between 1 and 3";
}
?>

Crash1hd
09-19-2005, 11:42 PM
thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum