Hi everyone, I was wondering if there is a script around that will change which CSS file the web page reads from depending on which is selected by the user. I have seen it before and am unsure if it will be PHP or JS. Thanks in advanced, much appreciated.
I think you are a bit confused... Anyway in PHP you can create a simple function that will change the style of the PAGE whenever you will need it or you can create a simple script that will store a CSS file for every page, or you can create a script that will change it randomly or you can create a script that will read from a database which style to load for a specified content or you can do a simple PHP script that will allow users (if we are talking about a website that allow registration) that will allow users to decide the template... But if you will clarify a bit your question we will be able to help you more
This should get you started, save it for example as style.php: <?php /* basic php example */ if($_GET['style'] == 'green'){ //green stylesheet... echo "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"".$_GET['style']".css\">"; } else if($_GET['style'] == 'blue'){ //blue stylesheet... echo "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"".$_GET['style']".css\">"; } else { //the default stylesheet, if none is selected. echo "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"default.css\">"; } ?> PHP: Then the user can select their style such as: style.php?style=green, and it would embed the green.css stylesheet... You can further enhance the code, using sessions etc.