Site Navigation Php

function printconstantlinks()
{
// Variables:
$lastcategory = FALSE; // The last link category seen. Cheat a bit here to say if we've seen a link category yet.
$serverlocation = "localhost";
$username = "mywebsiteusername";
$password = "mywebsiteuserpassword";
$db_name = "mywebsitedatabase";
// Now we want to display all the links we want on every page,
// Get a connection to the database first.
$conn = mysql_connect($serverlocation, $username, $password)
or die("Could Not Connect To Server");
mysql_select_db($db_name) or die("Could not use database for website");
// Now, we want to order our links by their category, and then their caption.
$query = "SELECT link_type, link_caption, link_location FROM internal_links ORDER BY link_type, link_caption";
$result = mysql_query($query) or die("Query failed.");
print "

";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
extract($line);
if ($lastcategory != $link_type)
{
if ($lastcategory)
print "
\n";
if ($link_type != "Navigation")
print "$link_type: ";
else
print "         ";
$lastcategory = $link_type;
}
if ($link_caption != "")
{
print " [ ";
for ($i = (15 - strlen($link_caption)) / 2; $i > 0; $i = $i - 1)
{
print " ";
}
print "";
print "$link_caption
";
for ($i = (15 - strlen($link_caption)) / 2; $i > 0; $i = $i - 1)
{
print " ";
}
if ((15-strlen($link_caption)) % 2 == 0)
print " ";
}
else
{
print " [ ";
print "";
print "$link_location
";
}
print " ]";
}
print "

\n";
mysql_free_result($result);
mysql_close($conn);
}
?>
#MySQL syntax to create internal_links table:
CREATE TABLE internal_links (
_handle INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
link_caption TEXT,
link_location TEXT NOT NULL,
link_type ENUM("Business", "Personal", "Projects", "Scholastic", "Navigation")
);