Css and php not working together

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
Homeboy
Forum Newbie
Posts: 6
Joined: Fri Aug 05, 2005 12:23 pm

Css and php not working together

Post by Homeboy »

I am new to php, I am having some minor issues which i know how to fix but it is not how i want to do it.

This is how i am doing my php for my website, I have 3 small template and the first on is header, second is right content, and the last is footer. In my header is obviously the css the meta tag and so on. OH yea one more thing i am using the include php tag.

1) First off, my css is not matching with the entire site, I don't want to use the full url like http://.... I want the exact ../style/css (like that). How can i do that?

2) Lastly, my main pages go to the other pages but not itself. So if you go to the home page click on home navigation button it will not find it. I don't want the absolute links like the first issue I want to be able to use relative links. How can i do that?

Here is the link to the site

http://abkdesign.com/eport1


THanks
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

PHP does not intertwine with CSS.

PHP is a pre-processing language, you use it to create output that it sends to the User Agent [browser - IE/FireFox/etc] (there are other features, but this is the primary one).

So, you need to ensure that the output the PHP script generates is relative to what you want. In your case, you want to output HTML + CSS.

As for the relations between CSS and HTML, when using external stylesheets, you link to them with the link meta-tag in the header:

Code: Select all

<link rel="stylesheet" type="text/css" href="./path/to/stylesheet.css"/>
Now - what you need to do is makesure the ./path/to/stylesheet.css is relative to the directory that the current file is in, and the directory that the stylesheet is in. Both files must be accessible by the user - the most common method to do this is have a sub-directory of the document root allocated for containing the stylesheet(s). The path must also be client-based, not server - so have the absolute path of /var/www/styles/stylesheet.css will not work for example, but http://www.yoursite.com/styles/stylesheet.css will.
Post Reply