•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 403,490 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,230 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1923 | Replies: 11
![]() |
•
•
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation:
Rep Power: 6
Solved Threads: 9
Ok, so I am a total PHP n00b so I will explain my problem then say how I would personally logically solve it.
I am creating a website using a php include at the top of the page (same for every page on the site) and one for the bottom of the page. Basically what I want to do is have (what I call) a tree at the top of my page inside my header include file. By tree I mean something like "Home> Tutorial> Html Tutorial > using tables Tutorial". This would of course change based on the page that is being viewed.
My logical solution:
Instead of my tree text in pure html I would have something like "home + Variable". The variable would then be specified at the top of my html file that is the content for the page.
I hope that all makes sense. I would be really grateful if someone could tell me how to do this using PHP. Thank in advance
I am creating a website using a php include at the top of the page (same for every page on the site) and one for the bottom of the page. Basically what I want to do is have (what I call) a tree at the top of my page inside my header include file. By tree I mean something like "Home> Tutorial> Html Tutorial > using tables Tutorial". This would of course change based on the page that is being viewed.
My logical solution:
Instead of my tree text in pure html I would have something like "home + Variable". The variable would then be specified at the top of my html file that is the content for the page.
I hope that all makes sense. I would be really grateful if someone could tell me how to do this using PHP. Thank in advance
•
•
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation:
Rep Power: 6
Solved Threads: 9
I really need help with this. If anyone can help me I would be very grateful!!!
•
•
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation:
Rep Power: 6
Solved Threads: 9
Hi guys,
I still haven't found an answer for this and it is vital for my site. I would be so grateful for any response. I will give a gmail invite to anyone who help me, I promise!!!
I still haven't found an answer for this and it is vital for my site. I would be so grateful for any response. I will give a gmail invite to anyone who help me, I promise!!!
•
•
Join Date: Oct 2006
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 1
ok here we go:
header.php
page.php
I hope that helps you out =)
header.php
<html> <body> Home > <?php echo $variable; ?>
page.php
php Syntax (Toggle Plain Text)
<?php $variable = "Current Page"; include "header.php"; ?>
I hope that helps you out =)
•
•
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation:
Rep Power: 6
Solved Threads: 9
You had me going for a bit but I have cracked it. It wasn't that you were wrong it was that I didn't realise that you had done the include for me too. Thank you very much mate excellent. Please see the gmail invite in your inbox!
•
•
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation:
Rep Power: 6
Solved Threads: 9
Another question related to this:
What happens if i want to turn all the parts of my tree into hyperlinks which will need to be from http:// upwards. Eg.
[PHP]<?php
$variable = ("<a href="http://www.mysite.co.uk/tutorials/">Tutorial</a>>
<span><a href="http://www.mysite.co.uk/tutorials/photoshop/">Photoshop Tutorial Home</a></span>");
include ("includes/header.php");
?>[/PHP]
Basically what happens is the tree goes through each page it is logical to go through to get to the current page and puts them as links and then has the page you are currently on inside span tags which I have used to make the text larger.
any help would be gratefully recieved.
What happens if i want to turn all the parts of my tree into hyperlinks which will need to be from http:// upwards. Eg.
[PHP]<?php
$variable = ("<a href="http://www.mysite.co.uk/tutorials/">Tutorial</a>>
<span><a href="http://www.mysite.co.uk/tutorials/photoshop/">Photoshop Tutorial Home</a></span>");
include ("includes/header.php");
?>[/PHP]
Basically what happens is the tree goes through each page it is logical to go through to get to the current page and puts them as links and then has the page you are currently on inside span tags which I have used to make the text larger.
any help would be gratefully recieved.
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 943
Reputation:
Rep Power: 5
Solved Threads: 47
if you arange your folders like a tree, and have each page as the folder index... then you can just link relatively to the folder above*, like this: "../". if you don't arrange your files into a neat and logical tree, i'd advise that you do.
*above being towards the http:// in matt-syntax
*above being towards the http:// in matt-syntax
Last edited by MattEvans : Dec 1st, 2006 at 4:52 pm.
If it only works in Internet Explorer; it doesn't work.
•
•
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation:
Rep Power: 6
Solved Threads: 9
Yes obviously but!
Because my folders are done nice and neatly and I do only have one header.php all the links must be done down to http:// otherwise when the html is inserted into the content php the links will break depending on which folder they are in. I hope this makes sense.
Still looking for an answer.. Anybody?
Because my folders are done nice and neatly and I do only have one header.php all the links must be done down to http:// otherwise when the html is inserted into the content php the links will break depending on which folder they are in. I hope this makes sense.
Still looking for an answer.. Anybody?
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 943
Reputation:
Rep Power: 5
Solved Threads: 47
hmmm, not sure I understand that? you should be able to include a file from the document root directory, by preceding it with a slash, ie:
... maybe that will go to your "home" directory though...
EDIT: Well, on my server, / goes to the server root folder. So, you'll need to know the path from the server root folder to your document root (public_html) folder. You can find that using:
For me, that's /home/fusion/public_html/(+ the path to the folder where the echo getcwd script is running in).
So, to get a file from the "includes" folder in my document root in PHP, I'd use:
This will be different for your server, and it may even be based from a "C:\" drive if you're hosted on a Windows flavour...
There is an environment variable you can use to find the server's document root I think, don't know which one, but it's probably DOCUMENT_ROOT... =)
EDIT (2): You should use absolute hrefs if your header includes ok but the links are 'broken'. Or, write some complex logic ^_-
include ("/includes/header.php");EDIT: Well, on my server, / goes to the server root folder. So, you'll need to know the path from the server root folder to your document root (public_html) folder. You can find that using:
<?php echo getcwd() ?>
So, to get a file from the "includes" folder in my document root in PHP, I'd use:
include ("/home/fusion/public_html/includes/header.php");This will be different for your server, and it may even be based from a "C:\" drive if you're hosted on a Windows flavour...
There is an environment variable you can use to find the server's document root I think, don't know which one, but it's probably DOCUMENT_ROOT... =)
EDIT (2): You should use absolute hrefs if your header includes ok but the links are 'broken'. Or, write some complex logic ^_-
Last edited by MattEvans : Dec 1st, 2006 at 7:43 pm.
If it only works in Internet Explorer; it doesn't work.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Image link in an email from php
- Next Thread: need help with order problem



Linear Mode