Thread: dynamic css
View Single Post

  #2 (permalink)  
Old 09-10-2006, 12:14 PM
louie's Avatar
louie louie is offline
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,040
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

First create the select menu.
Code:
<select name='style' id='style'>
<option value='_1'>style 1</option>
<option value='_2'>style 2</option>
</select>
then create the php code
Code:
<?php
$style_set = "_1";//set the default
if(@$_REQUEST['style'] <> ""){
  $style_set = $_REQUEST['style'];
  $_SESSION['set_style'] = $style_set;
  header("Location: ".$_SERVER['PHP_SELF']);//redirect so we can show the changes to the style
}
if(isset($_SESSION['set_style'])){$style_set = $_SESSION['set_style'];}
//set style if session isset
?>
then you have your stylesheet included
Code:
<?php
echo "<link rel=\"stylesheet\" href=\"style$style_set.css\" media=\"all\" />";
?>
if you don't want to use sessions or cookie store the value from the form in the database, then have a recordset pulling the data and set the
Code:
$style_set = rs['style'];
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory

Last edited by louie; 09-10-2006 at 12:53 PM.
Reply With Quote