help with urlencode on index.php
now what i want is this... in my main page index.php theirs a navigation menu thats database driven
now instead of just making traditional links like. www.mysite.com/business.php
i want the links to look like this - www.mysite.com/?q=Business
www.mysite.com/?q=Calendar
and so on...
how would I go about doing this within my index.php file?
this is the code I have so far..
code below represents which link is clicked, i think
<?php
include ('lib/config.php');
$link = $_GET['menu'];
$result = mysql_query("SELECT id,menu FROM wsd_nav")
or die(mysql_error());
while ($row = mysql_fetch_assoc($result))
{
if ($link == $row['menu'])
{
$id = $row['id'];
}
}
$result1 = mysql_query("SELECT id FROM wsd_nav WHERE menu = '{$id['menu']}'")
or die(mysql_error());
if ($result1['id'] == '1')
{
header ("Location: http://okauchee.fearfx.com/business/");
}
?>
This box of code below creates the navigation menu.
<?php
$result = mysql_query("SELECT id,menu FROM wsd_nav")
or die(mysql_error());
while ($row = mysql_fetch_assoc($result))
{
echo '<a href="?q=' . urlencode($row['menu']) . '">'
. htmlspecialchars($row['menu']) . "</a><br />\n";
}
?>
Now I want to know how to make this work, so when a link is clicked it goes to the corresponding page.