Click to See Complete Forum and Search --> : Navigation Bar Help


dpkyte
07-30-2005, 02:56 PM
I have a navigation bar that contains multiple divisions, each of these divisions have teams and standings. When the user selects their respective team I want to pull that information from a MySQL database and dynamically build the page based on the information retrieved.

So, I do not want to create 100 pages (one for each team). What I would like to do is when the user selects their respective team, I pass a variable to a PHP script and get the data.

Currently my navbar looks like:
<li><a href="team_1.php">Team 1</a></li>
<li><a href="team_2.php">Team 2</a></li>
<li><a href="team_3.php">Team 3</a></li>

What needs to be changed to have the href be the same file, but using a variable?

Thanks in advance.

DPK

NogDog
07-30-2005, 03:19 PM
Simplest way:

<li><a href="team.php?team=1">Team 1</a></li>
<li><a href="team.php?team=2">Team 2</a></li>
<li><a href="team.php?team=3">Team 3</a></li>

In team.php, produce your output based on the value of $_GET['team'].

if(!empty($_GET['team']))
{
# query database using team ID from $_GET['team'], then display data
}
else
{
# display default page, or error message, or whatever make sense here
}

dpkyte
07-31-2005, 12:27 PM
Thanks NogDog. This worked well.