Hi everyone... I'm working on a new site at the moment, and I'm exploring the idea of generating everything from a database. I come to you today with (I think) 2 problems...
I think my main problem is with the database design. I just can't seem to get my head around it!
Firstly.. I have generated this code for my menu and submenu. I havent yet come up with a way to generate a different submenu, depending on what main menu page im on.
Here is the code:
CODE
<?php
$username = "xxxxxx";
$password = "xxxxxx";
$database = "xxxxxx";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");
$query = "SELECT * FROM menu_table WHERE menu_id = 'mainmenu'";
$result = mysql_query($query) or die(mysql_error() . ' in ' . $query);
$num = mysql_numrows($result) or die(mysql_error() . ' in ' . $result);
$query2 = "SELECT * FROM menu_table WHERE menu_id = 'subNav'";
$result2 = mysql_query($query2) or die(mysql_error() . ' in ' . $query2);
$num2 = mysql_numrows($result2) or die(mysql_error() . ' in ' . $result2);
mysql_close();
?>
<div id="navigation-bg">
<div id="navigation">
<ul class="mainMenu">
<?php
$i=0;
while ($i < $num)
{
$Class = mysql_result($result,$i,"menu_Class");
$Title = mysql_result($result,$i,"menu_Title");
$Link = mysql_result($result,$i,"menu_Link");?>
<li><a href="<?php echo $Link ?>" class="<?php echo $Class ?>" title="<?php echo $Title ?>"><?php echo $Title ?></a></li>
<?php
$i++;
}?>
</ul>
<br class="spacer">
<ul class="subNav">
<?php
$i=0;
while ($i < $num)
{
if ( $i == "0" )
{
$Title = mysql_result($result2,$i,"menu_Title");
$Link = mysql_result($result2,$i,"menu_Link");
?>
<li class="noBg"><a href="<?php echo $Link ?>" title="<?php echo $Title ?>"><?php echo $Title ?></a></li>
<?php
}
else
{
$Title = mysql_result($result2,$i,"menu_Title");
$Link = mysql_result($result2,$i,"menu_Link");?>
<li><a href="<?php echo $Link ?>" class="<?php echo $Class ?>" title="<?php echo $Title ?>"><?php echo $Title ?></a></li>
<?php
}
$i++;
}?>
</ul>
</div>
</div>
Now... I've managed to get the main menu loading perfectly. I just have to add in an if statement later to get my css working, but thats not really important right now. What I'm having trouble doing, is getting the submenu to load a different set of values, depending on what link is clicked in the main menu. Where am I going wrong? What am I missing?
My next problem, is.. can i store the entire contents of my page in a database (will be 100% plain text, all images are handled with CSS), and load them into the correct divs the exact same way as i have done with the menus here?
Will i need to create a table with each page say as the UID, and then... I don't know... I fail at databases!

Any help is greatly appreciated, and thanks