|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
PHP and CSS
Hi..
I was wondering how I can include different css files. For example, want a visitor to be able to click on a link that would load the same page, with a different css file. Sort of like picking skins. Can anybody help me? I'd be very grateful! Thank-you. |
|
#2
|
|||
|
|||
|
Hi,
For your links' href attribute, which is your php script, include a query sting like this: href="your_php_script.php?css=style_1" href="your_php_script.php?css=style_2" href="your_php_script.php?css=style_3" Then in your php script do this: Code:
if ($css == style_1)
{
include('style_1.css');
}
else if ($css == style_2);
{
include('style_2.css');
}
else
{
include('style_3.css');
}
|
|
#3
|
|||
|
|||
|
Thank you so much! One question - does the code have to go in a certain place, or can it go anywhere?
Thanks again ![]() |
|
#4
|
|||
|
|||
|
Hi,
That's an html question: where would you normally have the text in the css file? The include() function just replaces itself with the text contained in the file you are including as if you had typed it there yourself. How about inside the <head> tags and between some <style> tags? Last edited by 7stud : June 19th, 2001 at 12:23 AM. |
|
#5
|
|||
|
|||
|
Though the other answers to this are also correct, another approach to this is through the use of JS.. most of the modern browsers can change css style sheets without reloading the document.
You can see examples of this at: http://www.projectseven.com/ They use such things as form buttons, to change the style of a page. Naturally the PHP approach can do this as well, only PHP will have to reload the page. Granted, you could couple the use of a cookie, so your visitor could actually return to your site, using the same style they selected previously. Pro's and Con's.. the first method I mention, does require JS being enabled.. not really a concern much these days.. I dunno.. I like the PHP idea far better ![]() |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > PHP and CSS |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|