I have a html header included with php include function however my context inside the index "Hi, World! is showing underneath my included header and not inside a html div from the header itself where I want. My screenshots:
The problem:
What I want:
So what i would like is the that my index:
<body>
<?php include('header.php'); ?>
<div >
<h3>Hi, <span class="">World!</span>
</h3>
</div>
</body>
shows inside the following div from my header.php:
<div class="content"> </div>
The problem was fixed by removing one </div> in this way the content is still opened to html further in an other document.
Related
I have a navigation bar and wrapper saved in header.php and have included it on my content.php page. but when i load the content.php page, the content from content.php is outside the wrapper from the header.php page.
<html>
<body>
<div class="navigation">
<?php include 'header.php'; ?>
<h1>Welcome to my home page.</h1>
<p>Some text.</p>
</div>
</body>
</html>
all help is greatly appreciated!
Because you define your wrapper for your navigation menu (which is in your header.php file). If you want your wrapper to wrap your whole document define this in your content.php file.
I know what to use and how.
Here is my script:
<html>
<body>
<div style="top:230px; right:50px"> // Style does not work
<?php include 'index.php'; ?>
</div>
<h1>Welcome to my home page.</h1>
<p>Some text.</p>
</body>
</html>
index.php contains this page:
http://yepinol.com/wall/
I want to place this content as specifi height, and location on the page. For that I added style as above. But it's height and left right position does not change?
Why?
index.php - source code of index.php
for top css attribute you need to add position. It has no effect on non-positioned elements.So do, like:
position: relative;
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a menu made with ul and li elements I use href to open a page when I click on one of the li , the problem is that I want to open the page that contains href in the same page in the main file, because I have a footer and a header.
A simple way to do it and without page refresh is to use AJAX technology and JS (+ just a bit of jQuery)
Search Engine friendly AJAX driven website:
BASIC EXAMPLE:
header.php
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>AJAX driven site - by Roko C.B. - TEST</title>
</head>
<body>
<?php include 'menu.html'; ?>
menu.html
<ul id="nav">
<li> HOME </li>
<li> FOO </li>
<li> BAR </li>
</ul>
footer.php
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script>
$(function(){ // DOM Ready (shorthand)
window.onpopstate = function(e) {
if(e.state){
$("#content").html( e.state.html );
document.title = e.state.pageTitle;
}
};
$('#nav a').click(function(e) {
e.preventDefault(); // prevent default anchor behavior
var URL = $(this).attr('href'); // get page URL
$('#page').html(''); // empty old HTML content.
// Target URL and get the #content element
// and put it into #page of this page
$('#page').load(URL +' #content', function(data){
// Load callback function.
// Everything here will be performed once the load is done.
// Put here whatever you need.
// ...
// Also, let's handle history and browser's AddressBar
var $data = $(data),
content = $data.find('#content').html(),
pageTitle = $data.find('h1').text();
window.history.pushState({"html":content, "pageTitle": pageTitle},"", URL );
});
});
});
</script>
</body>
</html>
Than all you need are your pages with the content:
index.php
<?php include 'header.php'; ?> <!-- header has menu.html -->
<div id="page">
<div id="content">
<h1>WELCOME!</h1>
<p>Article here...</p>
</div>
</div>
<?php include 'footer.php'; ?>
foo.php
<?php include 'header.php'; ?> <!-- header has menu.html -->
<div id="page">
<div id="content">
<h1>FOO!</h1>
<p>Foo Article here...</p>
</div>
</div>
<?php include 'footer.php'; ?>
bar.php
<?php include 'header.php'; ?> <!-- header has menu.html -->
<div id="page">
<div id="content">
<h1>BAR!</h1>
<p>Bar Article here...</p>
</div>
</div>
<?php include 'footer.php'; ?>
Documentation:
http://php.net/manual/en/function.include.php
http://api.jquery.com
http://api.jquery.com/load/
http://api.jquery.com/find/
http://api.jquery.com/html/
https://developer.mozilla.org/en-US/docs/Web/API/window.onpopstate
https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Manipulating_the_browser_history
What you need to do from reading you post is have the header and footer in their own separate files.
On all the pages include this header and footer where you want them, so when you open the new page up the header and footer will be the same across all the pages.
same for the menu. put it in its own file and include it in every page. then its always the same across every page and you only have to update one file.
#LazyBrain : then u just have to play around with id's.
for example:
<ul>
<li>Questions</li>
<li>Tags</li>
<li>Answers</li>
</ul>
<div id="questions">
....................
put your content for question page here
</div>
If you are using the target attribute within the href, take it out and you will open the link in the same window.
e.g.
Click Here - New window
Should be
Click Here - Current window
I believe this is what you are looking for, I've written a html page for you to demonstrate how you can use anchor tag to set your hyperlink reference(href) to the same page.
Try this
<html>
<body>
Go to footer
<div><a id="header">Your Header</a></div>
<div style="height:900px;"></div>
<div><a id="footer">Your Footer</a></div>
Go to Header
</body>
</html>
Update
Finally I got your problem, you want to use same footer and header on all your pages...Right??
Actually you are looking for a code that lets you use your already designed PHP files.
So you need just to use php include() function
Syntax:
Before your header section
<?php include 'header.php'; ?>
Before your footer section
<?php include 'footer.php'; ?>
Note:
You can also use <?php require 'header.php'; ?>
but this can generate an error in case your header and footer files are missing.
The <div id="page>" and <div id="pagecontent"> don't show in on my webpage. In Firebug, the "Script" tab shows that index.php has both of these divs in it, but the HTML tab doesn't show either div. Why?
All of the content is generated by PHP, and everything shows correctly on the page except for these two divs. Both divs are immediately after the <body> tag. The active website with this problem can be found here.
HTML document:
<?php include "topofpage.php" ?>
<!--Main Content Area-->
<div id="main">
<!-- TABLE HTML GOES HERE, BUT IT'S KINDA LONG AND BORING AND THE PROBLEM ISN'T HERE SO I TOOK IT OUT -->
<!--Copyright Notice-->
<p><br />
<div id="divdate">© 2009-2025 Poet Slam. All rights reserved.</div><br />
<script type="text/javascript">
var divisiondate=document.getElementById("divdate"); var newdater=new Date(); var years=newdater.getFullYear(); divisiondate.innerHTML="© 2013-"+years+" Poet Slam. All rights reserved.";
</script>
</div> <!-- THIS CLOSES THE <DIV ID="PAGECONTENT"> CREATED IN THE EXTERNAL PHP FILE
</div> <!--THIS CLOSES THE <DIV ID="PAGE"> CREATED IN THE EXTERNAL PHP FILE
</body>
</html>
it's a small thing, but looking at line 49 in the page source you have an unclosed comment
<!--CREATE A POEM * TAG DRAG AND DROP->
Running the page as it stands through the W3CValidator - http://validator.w3.org/ - shows that causes a few errors that might be throwing the DOM parser.
As a first step I'd suggest fixing that, and iterating through the validator to at least knock off the (unexpected) errors
My form create by php script and between teo file:
index.php
header.php
In index.php, i try in
...
<div class="art-header-png"></div>
<div class="art-header-jpeg"></div>
<?php include("header.php"); ?>
</div>
<div class="art-nav">
<div class="l"></div>
<div class="r"></div>
and my header.php
<div class="art-logo">
<h1 id="name-text" class="art-logo-name">Your Title Goes Here</h1>
<div id="slogan-text" class="art-logo-text">Your Slogan Goes Here</div>
</div>
But it didn't show content inside header.php.
How can i make it work?
First thing, either place header.php in the same folder as index.php or specify the correct path relative to index.php when you are using include (same apply to require).
PHP Include
also check to see if your php is configured correctly as well. Save the following line of code in a php file. Run it and see if you get php window:
<?php
phpinfo();
?>