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;
Related
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.
I am a beginner, just trying to learn php. Below is my index.php file:
<?php
include("header.php");
require_once('connect.php');
include("home.php");
include("footer.php");
?>
I made a simple test site that has the home page included inside the index.php file. Do I have to use include(header.php); on every page if I want to include the same code?
Thanks.
You dont have include header.php on every page.
Try this:
<?php include("header.php");?>
<div class="container">
<?php include ("home.php");?>
</div>
<?php include ("footer.php");?>
Keep the header and footer, just change the contents( home.php, otherpage.php, ... ).
I recommend you to use jQuery to dynamically load the content of container
I've run into problem whereby I'm not able to include a header file into a PHP file
In the code below, I've removed the original content as it's quite big & anyway what the code does is irrelevant to including the header file
MAIN.PHP
<?php
php content
?>
<html>
<head>
</head>
<body >
<div>
header content
</div>
<br/>
<div>
</div>
</body>
</html>
I would like to have the following code in the header.php file & include it on all pages.
<div>
header content
</div>
When I do so with the main.php file looking as below, the page draws blank.
<?php
php content
?>
<html>
<head>
</head>
<body >
<div>
<? php include('header.php') ?>
</div>
<br/>
<div>
</div>
</body>
</html>
I've tried debugging this & following a few solutions on stackoverflow, but evidently have failed to achieve what I'm after.
Could I please request a second pair of eyes to help me spot the problem?
Well, first of all, I don't think you copied the code correctly to here.
As my debugging eyes can see, you got 2 issues:
Line 1: < is missing at the start. Change it to <?php. (Maybe
copy paste error?)
<?php include('header.php'); is missing closing tag. Change it to:
<?php include('header.php'); ?>
If you get a blank page, you probably have some errors. Try finding the "error.log" file in you working directory or add the following code at the start of the page:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
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.
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.