We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

PHP Includes Advice

Hi guys

I'm building a website at the moment for a friends company and as it's going to have about 25 pages I have decided to use PHP includes for the header/footer which include images/dhtml menu to save me a lot of time hard coding each page.

Normally in Dreamweaver I specify the location of images as something like images/imagename.jpg which works fine on the index.php page so I went ahead and created a menu.htm page and included it within the index.php page. Uploaded it and bingo - works fine one template page built quickly.

Anyway my next task was to set about creating an ABOUT US page so I created a new folder (called about), saved a copy of index.php as about.php, changed a bit of text, uploaded, then I noticed half the images were missing.

Am I right in thinking for php includes (eg for menu's) I would need to specify the full location of the images ie:- www.blahblah.com/images/dodgy.jpg in the MENU.HTM page?

I found a tutorial here and it didn't mention anything about that.

Hope I've explained myself clearly enough, newbie to PHP includes

WJUK

Comments

  • DrBenway
    DrBenway Posts: 256 Forumite
    How about:

    ../images/imagename.jpg

    You seem to have moved down a dir level into "about" so you need to get back up a level before going into images. Much better than creating another http request. Check relative versus absolute paths in any html tuturial.
    NURSE: "Shouldn't it be sterilized, doctor?"
    DR. BENWAY: "Very likely but there's no time."
  • zenmaster
    zenmaster Posts: 3,151 Forumite
    If you are likely to be doing a lot of similar things in the future (or even if you are just interested) and are prepared to spend a small amount of time in learning the basics, I suggest that you look at a CMS.

    There are a number of popular packages out there (Joomla springs to mind) but my personal favourite is ModX.
  • DrBenway wrote:
    How about:

    ../images/imagename.jpg

    You seem to have moved down a dir level into "about" so you need to get back up a level before going into images. Much better than creating another http request. Check relative versus absolute paths in any html tuturial.
    Yup, that should do it.
  • wolfman
    wolfman Posts: 3,225 Forumite
    Or just use /images/...

    By putting the slash at the beginning it'll reference it from the web root, no matter where you are.

    In .Net you can do ~/images/... which will reference it from the current application (in case you have virtual directories). There may be something similar in PHP worth looking up.
    "Boonowa tweepi, ha, ha."
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 352.4K Banking & Borrowing
  • 253.7K Reduce Debt & Boost Income
  • 454.4K Spending & Discounts
  • 245.4K Work, Benefits & Business
  • 601.3K Mortgages, Homes & Bills
  • 177.6K Life & Family
  • 259.3K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.