Hey everyone.
I am working on a website for a friend and I have finished designing the website and have now started developing it.
What I am trying to do but am having problems with is making a menu that uses two tables in the database. menu and menuPerms. Below are the table structures.
menu
menuPerms
Below is my code but it doesn't work and I am not too sure about what to do.
//menu
$menuQ = $db->query( "SELECT * FROM `menu` ORDER BY `sort` ASC" );
while( $menu = $menuQ->fetch_assoc() ) {
$autoId = $menu['autoId'];
$class = $menu['class'];
$href = $menu['href'];
$id = $menu['id'];
$onClick = $menu['onClick'];
$target = $menu['target'];
$title = $menu['title'];
$text = $menu['text'];
if( $class != '' ) {
$class = ' class="' . $class . '"';
}
if( $href != '' ) {
$href = ' href="' . $href . '"';
} else {
$href = ' href="#"';
}
if( $id != '' ) {
$id = ' id="' . $id . '"';
}
if( $onClick != '' ) {
$onClick = ' onClick="' . $onClick . '"';
}
if( $target != '' ) {
$target = ' target="' . $target . '"';
}
if( $title != '' ) {
$title = ' title="' . $title . '"';
} else {
$title = ' title="' . $text . '"';
}
//menu perms
$menuPermsQ = $db->query( "SELECT * FROM `menuPerms` WHERE `menuId` = '" . $autoId . "'" );
$menuPerms = $menuPermsQ->fetch_assoc();
$menuLoggedIn = $menuPerms['loggedIn'];
$menuLoggedOut = $menuPerms['loggedOut'];
$menuAdmin = $menuPerms['admin'];
if( $menuLoggedOut == 1 && isLoggedIn() == 0 ) {
echo '<li><a' . $class .''. $href .''. $id .''. $onClick .''. $target .''. $title .'>' . $text . '</li>';
}
}
Any help would be very much appreciated.
Thanks in advance