Thread: dynamic css
View Single Post

  #5 (permalink)  
Old 09-10-2006, 12:53 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

have a look here:

Code:
<?php session_start(); 
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="XHTML namespace">
<?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
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?php
echo "<link rel=\"stylesheet\" href=\"style$style_set.css\" media=\"all\" />";
?>
</head>
<body>
<form name="select_style" action="x_style_set.php" method="post">
 <select name="style" onChange='this.form.submit();'>
  <option value='_1' <?php if($style_set == "_1"){echo "selected";}?>>style 1</option>
  <option value='_2' <?php if($style_set == "_2"){echo "selected";}?>>style 2</option>
 </select>
</form>
<?php echo "your style that you have selected is - <b>style$style_set.css</b>";?>
</body>
</html>

Last edited by louie; 10-10-2006 at 08:12 AM. Reason: added code
Reply With Quote