带变量的导航菜单

I am trying to implement dashboard kind of system. And having problem with passing variable in navigation menu items.

At first user selects "Workspace Name" from list of workspaces. That link redirects user to projects.php?workspaceid=xxxxxx

Now inside project.php , there is sidebar (static) with other options like projectsettings.php , credentials.php.

I want to pass variable workspaceid in each sub menu items. Like projectsettings.php?workspaceid=xxxxxx or credentials.php?workspaceid=xxxxxx

How can I do so ?

UPDATE : I think i was quite unclear about question.

At first user comes to workspaces.php It looks like

![workspace selection table] http://i.stack.imgur.com/eBtSm.png

Then for example they select "internet explorer 7" from table. Link will take them to project.php?workspaceid=IE7

It looks like ![Project dashboard] http://i.stack.imgur.com/EfdK1.png

Here all menus (data menus, data variable, setting.php) should have variable of workspace.

EDITED ANSWER: You need to set a session once the workspaceid is set

<?php
session_start();

    if (isset($_SESSION['workspaceid'])){
        //do what you need with this info
    }
    else if (isset($_GET['workspaceid'])){
        //lets set the session
         $_SESSION['workspaceid'] = trim(strip_tags($_GET['workspaceid']));
    }
    else {
        //do nothing
    }

//with this method there is no need to pass the workspaceid via url
?>

Original answer:

echo the variable in each link you need.

<a href="projectsettings.php?workspaceid=<?php echo $_GET['workspaceid']; ?>">link text</a>

With get variables you should be careful. I usually check and clean them in the header. So a more advanced way to do this is as follows

<?php
    if (isset($_GET['workspaceid']){
        $workspaceid = trim(strip_tags($_GET['workspaceid']));
    }
?>

Then in the link check for isset as well

 <a href="projectsettings.php?workspaceid=<?php echo isset($workspaceid)?$workspaceid:''; ?>">link text</a>

You can do something like:

<?php
if(isset($_GET['workspaceid']))
    $workspaceid = htmlspecialchars($_GET['workspaceid']);
else
    $workspaceid = '';

$query = "SELECT * FROM table WHERE workspaceid = ?";

if($stmt = $mysqli->prepare($query)){
     $stmt->bind_param('i',$workspaceid);
     $stmt->execute();
     $result = $stmt->get_result();

     while($row = $result->fetch_assoc()){
         $variablename = $row['columnname']; //put your own in here 
     }

     $stmt->free_result();
     $stmt->close();

}else die("Query failed to prepare");

The you can navigate by using credentials.php?workspaceid=xxxxxx"