我正在使用PHP包括在我的网页上包含页眉和页脚。我在所有标题上都有一个导航栏,并且想知道是否有办法让header.phph在某些页面上不显示某些导航项目。例如,用户不需要从联系页面导航到联系页面,因此该导航项目不是必需的。希望有人能够协助。PHP包含,但只有某些东西
的index.php
<?php
include('header.php');
?>
<div class="third_bar">
<div class="second_image">
</div>
<div class="form">
<form action= "search.php" method="post">
<input type="text" id="search_bar" placeholder="" value="Search" max length="30" autocomplete="off" onMouseDown="active();" onBlur="inactive();"/><input type="submit" id="search_button" value="Go!"/>
</form>
</div>
</div>
<?php
include ('footer.php');
?>
的header.php
!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="icon" href="http://www.com/favicon.png?v=2"/>
<title>Wcom</title>
<link rel= "stylesheet" href="style5.css"/>
</head>
<script type="text/javascript">
function active() {
var search_bar= document.getElementById('search_bar');
if(search_bar.value == 'Search here') {
search_bar.value=''
search_bar.placeholder= 'Search here'
}
}
function inactive() {
var search_bar= document.getElementById('search_bar');
if(search_bar.value == '') {
search_bar.value='Search here'
search_bar.placeholder= ''
}
}
</script>
<div id="container">
<div class="top_section">
<div class="first_image">
<a href="#"><img src="logo.png"/></a>
</div>
</div>
<div class="nav_bar">
<a href ="#"> About us</a>
<a href ="#"> Products & Pricing</a>
<a href ="contactpage.php"> Contact us</a>
<a href ="#"> login</a>
</div>
<!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="icon" href="http://"/>
<title>?.com</title>
<link rel= "stylesheet" href="style5.css"/>
</head>
<script type="text/javascript">
function active() {
var search_bar= document.getElementById('search_bar');
if(search_bar.value == 'Search here') {
search_bar.value=''
search_bar.placeholder= 'Search here'
}
}
function inactive() {
var search_bar= document.getElementById('search_bar');
if(search_bar.value == '') {
search_bar.value='Search here'
search_bar.placeholder= ''
}
}
</script>
<div id="container">
<div class="top_section">
<div class="first_image">
<a href="#"><img src="logo.png"/></a>
</div>
</div>
<div class="nav_bar">
<a href ="#"> About us</a>
<a href ="#"> Products & Pricing</a>
<a href ="contactpage.php"> Contact us</a>
<a href ="#"> login</a>
</div>
荣誉的网站上的工作威士忌! –
那么有人必须这样做,它是一种艰苦的生活。 – Bill04
你应该在'header.php'代码中实现一个逻辑,该代码决定显示哪些内容,哪些不显示。实际上你可以通过使用客户端逻辑来隐藏事物。 – arkascha