Hello,
I'm hoping someone can help me with this. What I'm trying to do is create a navigation system that uses variables in the url to select the page information form a database and then display it. I have a configure file, a page file, and the index file. The main part is the links in the navigation wont insert the information in to the variable so i can access it. You don't need the index page because it's in html. Thanks in advance.
Here's the code:
Config.php
<?
function display ( $page ) {
$DBhost = "localhost";
$DBuser = "user";
$DBpass = "pass";
$DBName = "db";
$table = "site";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "SELECT * FROM $table WHERE ( name = '%page' )";
$result = mysql_query($sqlquery);
$number = mysql_num_rows($result);
$i = 0;
if ($number < 1) {
print "<CENTER><P>There Were No Results for Your Search</CENTER>";
}
else {
while ($number > $i) {
$id = mysql_result($result,$i,"id");
$name = mysql_result($result,$i,"name");
$title = mysql_result($result,$i,"title");
$text = mysql_result($result,$i,"text");
print "<BR><BR>$text<BR><BR>";
$i++;
}
}
};
$aboutus = "page=" .urlencode( aboutus );
$contactus = "page=" .urlencode( contactus );
$navigation = "<table width='100%' bgcolor='#000080'>
<tr>
<td><a href='index.htm'>Home</a></td>
<td><a href='page.php?page=aboutus'>About Us</a></td>
<td><a href='page.php?page=contactus'>Contact Us</a></td>
<td><a href='shop.php'>Shop</a></td>
<TD></td>
</tr>
</table>
";
?>
page.php
<? include("config.php"); ?>
<HTML>
<HEAD>
<TITLE><? print "$title"; ?></TITLE>
<style>
<!--
body {cursor: default;
scrollbar-face-color: #FFFFFF;
scrollbar-highlight-color: #000080;
scrollbar-3dlight-color: #FFFFFF;
scrollbar-darkshadow-color: #FFFFFF;
scrollbar-shadow-color: #000080;
scrollbar-arrow-color: #000080;
scrollbar-track-color: #FFFFFF;}
a {text-decoration: none; }
a:hover {color: #0000CC; }
<!--
</style>
</HEAD>
<body bgcolor="#FFFFFF" text="#000080" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<table border="0" width="760" cellspacing="0" cellpadding="0" height="100" bgcolor="#FFFFFF">
<tr>
<td width="100%">
<P align="center"></P>
</td>
</tr>
</table>
<? print "$navigation"; ?>
</table>
<table
<table border="0" width="760" cellspacing="0" cellpadding="0">
<tr width='150'>
<TD></TD>
</tr>
</table>
</td>
<td width="760" valign="top">
<table border="0" width="570" bordercolor="#FFFFFF" cellspacing="0" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" cellpadding="2">
<tr>
<td width="100%" bordercolor="#000080" bgcolor="#FFFFFF"><BR>
<?
display ( $page );
?>
<P> </P>
<p> </p>
<p> </p>
</td>
</tr>
</table>
</body>
</HTML>