linking pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
amirbwb
Forum Commoner
Posts: 89
Joined: Sat Oct 30, 2010 6:10 pm

linking pages

Post by amirbwb »

hello .. i'm creating a website but i faced a problem in the page structure ...
i want in the bottom to each page to have a small bar like the menu bar example http://www.psd2html.com/
so i created a page call nav.php in a directory named "inc".

let's say that nav.php contain this code:

[text]<div>
<ul>
<li><a href="index.php">home</a></li>
<li><a href="about.php">about</a></li>
<ul>
</div>[/text]

in the public_html/index.php when i use
require('inc/nav.php');
every thing work fine but when i enter to a directory lets say public_html/admin/index.php
and i use require('../inc/nav.php');

the text appears but the link are not correct for the <li>about<li> it will post public_html/admin/about.php
i wanted to be updated automaticaly in each page like this public_html/about.php

In fact i am using this method to not repeat the same code in each page and if i want to update it i will update it one time only ...
thanks for help hope u understand what i want ...
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: linking pages

Post by DigitalMind »

Code: Select all

<a href="/index.php">home</a>
<a href="/about.php">about</a>
Is that what you want?
User avatar
amirbwb
Forum Commoner
Posts: 89
Joined: Sat Oct 30, 2010 6:10 pm

Re: linking pages

Post by amirbwb »

noo i want them to be in the admin directory index page <a href="../index.php">home</a>
and in the homepage (public_html/index.php) <a href="index.php">home</a>

but i want to require the same page each time ...
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: linking pages

Post by DigitalMind »

I thought my code solves the issue. Did you try it?
User avatar
amirbwb
Forum Commoner
Posts: 89
Joined: Sat Oct 30, 2010 6:10 pm

Re: linking pages

Post by amirbwb »

yeah yeah sory i didn't pay attention to the " / " .. thanks for ur helppppp ... ^^
Post Reply