Page 1 of 1

Need help with switches and links

Posted: Sun Oct 24, 2010 10:21 pm
by Gimpy
Alright, Im trying to relearn php as it has been about a year or two since I actually used it and im a lil rusty with making links with switches on the page. I have heard rumors that the php5.x.x has broke the simplification of this. If this is true what is the best practice? saving links in arrays or variables? Could use some insight?'

Here is what Im messing with so far -

Code: Select all

<div style="text-align:center">Home | <a href="<? =$_SERVER['PHP_SELF']; ?>?nav=time">Project 1</a>|
		<a href="<? =$_SERVER['PHP_SELF']; ?>?nav=p2"> Project 2</a> | Project 3 | Project 4
and here is the switch:

Code: Select all

switch ($nav) {
case "time":
//include '/projects/timeclock/index.php';
header('Location: /projects/timeclock/index.php');
break;
case "p2":
echo "i equals 1";
break;
case "p3":
echo "i equals 2";
break;
case "p4":
echo "i equals 2";
break;
default:
include 'home.php';
}
Thanks,
Gimpy

Re: Need help with switches and links

Posted: Mon Oct 25, 2010 12:01 am
by requinix
Looks like it will work fine as long as you set the value of $nav:

Code: Select all

$nav = (empty($_GET["nav"]) ? "" : (string)$_GET["nav"]);