Bootstrap下拉列表没有工作包括标题php

时间:2015-11-06 19:35:38

标签: php html css drop-down-menu twitter-bootstrap-3

我有两个页面home.php和header.php现在头文件有顶部导航栏,它将包含在home.php页面中。我在header.php中使用了一个bootstrap下拉,它正在工作很好但是当我在home.php中包含header.php时,导航栏看起来很完美,但是下拉列表没有工作所以请帮助。这是我的代码
的header.php



<?php
if(!isset($_SESSION)) 
    { 
        session_start(); 
    } 
if(isset($_SESSION['user']))
{
	$user=$_SESSION['user'];
}
?>
<!DOCTYPE HTML>
<html>
<head>
	<link rel="SHORTCUT ICON" href="images/icon/logo.ico">
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" media="all" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
	</head>
<body>
<?php
require_once("dbconnect.php");
$query="SELECT * FROM user WHERE email='{$user}'";
$result=mysqli_query($con,$query);
$row=mysqli_fetch_array($result);
$name=ucfirst($row[1]);
?>
	<!--Navigation bar-->
	<div class="navi">
	<nav class="navbar navbar-default navbar-fixed-top navbar-inverse">
		<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span> 
				</button>
				<div class="navbar-brand">&nbsp;&nbsp;&nbsp;Rankethon</div>
				<form role="search" class="navbar-form navbar-left">
			<div class="input-group">
						            <input type="text" class="form-control" placeholder="Search for friends.." size="50" id="query" name="search" value="">
							            <div class="input-group-btn">
						            <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-search"></span></button>
						            </div>
						        </div>
			</form>
			</div>
			<div class="collapse navbar-collapse" id="myNavbar">
				<ul class="nav navbar-nav navbar-right">
					<li><a href="#"><span class="glyphicon glyphicon-home" aria-hidden="true"></span><b> Home</b></a></li>
					<li><a href="#"><span class="glyphicon glyphicon-user" aria-hidden="true"></span><?php echo "<b>$name</b>";?></a></li>
					<li><a href="#"><span class="glyphicon glyphicon-tags" aria-hidden="true"></span><b> Noifications</b></a></li>
					<li class="dropdown">
					<a id="dLabel" data-target="#" href="#" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
					<span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
					<b>Account</b>
					<span class="caret"></span>
					<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dLabel">
					<li><a href="#" style="text-align:center"><b>Settings</b></a></li>
					<li><a href="#" style="text-align:center"><b>About Us</b></a></li>
					<li role="separator" class="divider"></li>
					<li><a href="logout.php" style="text-align:center"><strong>Logout</strong></a></li>
					</ul>
					</a>
					</li>
		</div>
	</nav>
</body>
</html>
&#13;
&#13;
&#13;

home.php

&#13;
&#13;
<?php
if(!isset($_SESSION)) 
    { 
        session_start(); 
    } 
if(!(isset($_SESSION['user'])))
{
	header('location:logout.php');
}
?>
<!DOCTYPE HTML>
<html>
<head>
	<link rel="SHORTCUT ICON" href="images/icon/logo.ico">
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" media="all" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
	<script> $(document).ready(function () { $('.dropdown-toggle').dropdown(); }); </script>
</head>
<body>
<?php
include("header.php");
?>
</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

发生这种情况是因为标记无效,因为您将html标记嵌入了两次。

此致 帕特里克