Navigation problem

This has PHP I was told to go here

Page 1 of 1

5 Replies - 413 Views - Last Post: 31 December 2010 - 12:03 PM

#1 EnvXOwner  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 357
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Navigation problem

Posted 31 December 2010 - 11:11 AM

Hello, I'm having a problem with my navigation on my website. As you can see here:
Attached Image
I originally posted this question in the PHP forum (for I thought that it was my PHP) and was told to ask on here. The code does have PHP in it. I'm using HTML5 and CSS3. Here is the code:
			<nav>
				<ul class="menu">
					<li class="title"><a id="1" href="#1"><span>Main</span></a>
				<ul>
					<li><a href="index.php">Home</a></li>
					<li><a href="about.php">About</a></li>
					<li><a href="login.php">Login</a></li>
					<li><a href="register.php">Register</a></li>
				</ul>
					</li>
				<?php
					if($_SESSION['username'])
					{
						echo "<li class='title'><a id='5' href='#5'><span>Profile</span></a>";
						echo "<ul>";
							$sql = "SELECT * FROM `users` WHERE `username`='".$_SESSION['username']."'";
							$res = mysql_query($sql) or die(mysql_error());
							$row = mysql_fetch_assoc($res);
						if($row['admin'] == '1')
						{
							echo "<li><a href='admin.php'>Admin</a></li>";
						}
						echo "<li><a href='profile.php'>View Profile</a></li>";
						echo "<li><a href='#'>Edit Profile</a></li>";
						echo "<li><a href='scripts/logout.php'>Logout</a></li>";
						echo "</ul>";
						echo "</li>";
					}
				$admin_user_level = $row['admin'];
				if(!$action || !in_array($action, $actions_array))
				{
					$sql1 = "SELECT * FROM `forum_cats` WHERE `admin` < ".$row['admin']."+1";
					$res1 = mysql_query($sql1) or die(mysql_error());
					
					while($row2 = mysql_fetch_assoc($res1))
					{
						if($row2['name'] == "Programming and Web Development Help")
						{
						echo " <li class=\"title\"><a id=\"2\" href=\"#2\"><span>".$row2['name']."</span></a>";
						}
						if($row2['name'] == "Programming and Web Development Tutorials")
						{
						echo " <li class=\"title\"><a id=\"3\" href=\"#3\"><span>".$row2['name']."</span></a>";
						}
						if($row2['name'] == "Moderation")
						{
						echo " <li class=\title\"><a id =\"6\" href=\"#6\"><span>".$row2['name']."</span></a>";
						}
						if($row2['name'] == "Homework Help")
						{
						echo " <li class=\"title\"><a id=\"4\" href=\"#4\"><span>".$row2['name']."</span></a>";
						}
						$sql2 = "SELECT * FROM `forum_sub_cats` WHERE `cid`='".$row2['id']."' AND `admin` < ".$row['admin']."+1";
						$res2 = mysql_query($sql2) or die(mysql_error());
						echo " <ul>";
						
						while($row3 = mysql_fetch_assoc($res2))
						{
						echo " <li><a href=\"./index.php?act=forum&id=".$row3['id']."\"id=\"link\">".$row3['name']."</a></li>";
						
					}
						echo " </ul>";
						
						}
						echo "</li>";
				}else{
					if($action == 'forum')
					{
						echo " <div id=\"forum_topics\">";
						include "scripts/forum.php";
						echo " </div>";
					}
					if($action == 'create')
					{
						include "scripts/create.php";
					}
				}
				?>
					<li id="bottom"><p>C0dingF0x</p><ul></ul></li>
				</ul>
			</nav>


Here is my CSS:
a 
{
	text-decoration: none;
}
.menu
{
	position: absolute;
	width: 200px;
	border-radius: 20px;	
	background: #e3e3e3;
	list-style: none;
	border: 1px solid #b2b2b2;
	background-image: -webkit-gradient(linear,left bottom,left top, from(#c3c3c3), to(#f5f5f5)); 
	background-image: -moz-linear-gradient(bottom, #c3c3c3, #f5f5f5);
	box-shadow: #aaa 0px 4px 10px;
}
 
.title
 {
	overflow: hidden;
	border-top: 1px solid #fff;
}
 
.menu li.title:first-child 
{
	border-top: none;
}
 
.title a span 
{
	display:block;
	padding:10px 10px 10px 20px;
	color: #000;
}
 
.title ul li a 
{
	display: block;
	padding-left: 20px;
	line-height: 30px;
	text-decoration: none;
	font-size: 14px;
	background: #fff;
	color: #464646;
	
}
 
.title ul li a:hover
{
	background: #bbc5cf;
	color: #000;
	
}
 
 
.title ul li a
{
 	-webkit-transition: all .5s ease-in-out;
	-moz-transition: all .5s ease-in-out;
 	height: 0px;
	display: block;
 	
 }
 
:target + ul li a 
{
	height: 30px;
	
}

Thanks in advance!

Is This A Good Question/Topic? 1
  • +

Replies To: Navigation problem

#2 EnvXOwner  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 357
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Re: Navigation problem

Posted 31 December 2010 - 11:25 AM

Never mind I fixed it. I'm sorry.
Was This Post Helpful? 0
  • +
  • -

#3 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 789
  • View blog
  • Posts: 1,676
  • Joined: 30-January 09

Re: Navigation problem

Posted 31 December 2010 - 11:31 AM

Line 47 is missing a quotation mark:

echo " <li class=\title\"><a id =\"6\" href=\"#6\"><span>".$row2['name']."</span></a>";



...should be...

echo " <li class=\"title\"><a id =\"6\" href=\"#6\"><span>".$row2['name']."</span></a>";



Also, you might want to change line 59 from this:

echo " <li><a href=\"./index.php?act=forum&id=".$row3['id']."\"id=\"link\">".$row3['name']."</a></li>";



...to this...

echo " <li><a href=\"./index.php?act=forum&id=".$row3['id']."\" id=\"link\">".$row3['name']."</a></li>";



...and also change the id on those links, because they're in a loop so they'll generate multiple DOM elements with the same id.
Was This Post Helpful? 1
  • +
  • -

#4 EnvXOwner  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 357
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Re: Navigation problem

Posted 31 December 2010 - 11:32 AM

View Poste_i_pi, on 31 December 2010 - 12:31 PM, said:

Line 47 is missing a quotation mark:

echo " <li class=\title\"><a id =\"6\" href=\"#6\"><span>".$row2['name']."</span></a>";



...should be...

echo " <li class=\"title\"><a id =\"6\" href=\"#6\"><span>".$row2['name']."</span></a>";



Also, you might want to change line 59 from this:

echo " <li><a href=\"./index.php?act=forum&id=".$row3['id']."\"id=\"link\">".$row3['name']."</a></li>";



...to this...

echo " <li><a href=\"./index.php?act=forum&id=".$row3['id']."\" id=\"link\">".$row3['name']."</a></li>";



...and also change the id on those links, because they're in a loop so they'll generate multiple DOM elements with the same id.

So I should make them like around 100? I don't think that I'll get that many subcategories.
Was This Post Helpful? 0
  • +
  • -

#5 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 789
  • View blog
  • Posts: 1,676
  • Joined: 30-January 09

Re: Navigation problem

Posted 31 December 2010 - 11:38 AM

What I mean is this piece of code:
while($row3 = mysql_fetch_assoc($res2))
{
	echo " <li><a href=\"./index.php?act=forum&id=".$row3['id']."\"id=\"link\">".$row3['name']."</a></li>";
}


...is going to generate something like...
<li><a href="./index.php?act=forum&id=Banana" id="link">Banana</a></li>
<li><a href="./index.php?act=forum&id=Orange" id="link">Orange</a></li>
<li><a href="./index.php?act=forum&id=Apples" id="link">Apples</a></li>


All those anchors will have the same id, better to use this code:
while($row3 = mysql_fetch_assoc($res2))
{
	echo " <li><a href=\"./index.php?act=forum&id=".$row3['id']."\" id=\"link" . $row3['id'] . "\">".$row3['name']."</a></li>";
}


...so that it generates unique ids for each link
Was This Post Helpful? 1
  • +
  • -

#6 EnvXOwner  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 357
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Re: Navigation problem

Posted 31 December 2010 - 12:03 PM

View Poste_i_pi, on 31 December 2010 - 12:38 PM, said:

What I mean is this piece of code:
while($row3 = mysql_fetch_assoc($res2))
{
	echo " <li><a href=\"./index.php?act=forum&id=".$row3['id']."\"id=\"link\">".$row3['name']."</a></li>";
}


...is going to generate something like...
<li><a href="./index.php?act=forum&id=Banana" id="link">Banana</a></li>
<li><a href="./index.php?act=forum&id=Orange" id="link">Orange</a></li>
<li><a href="./index.php?act=forum&id=Apples" id="link">Apples</a></li>


All those anchors will have the same id, better to use this code:
while($row3 = mysql_fetch_assoc($res2))
{
	echo " <li><a href=\"./index.php?act=forum&id=".$row3['id']."\" id=\"link" . $row3['id'] . "\">".$row3['name']."</a></li>";
}


...so that it generates unique ids for each link

Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1