WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : CSS style switcher
Categories : PHP, CSS, HTML and PHP, Arrays, Sessions Click here to Update Your Picture
Olaf Lederer
Date : Jul 12th 2005
Grade : 3 of 5 (graded 4 times)
Viewed : 9747
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Olaf Lederer
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

A lot of webmasters like this nice looking CSS websites with the possibility to switch between different CSS style sheets. This code snippet will help to create the switch. Just create you different style sheets and your universal coded html documents (these one have to work with all the style sheets) and at least use this code in all html documents (or with a PHP included file). Notice the links at the bottom of this site; they are created with the same function. After a visitor changed the style, his choice is stored inside a session variable.

<?php
session_start
();
$all_css = array();

$all_css['yellow']['file'] = "home_geel.css";
$all_css['blue']['file'] = "home_blauw.css";
$all_css['modern']['file'] = "home_modern.css"; // default

$all_css['yellow']['label'] = "Yellow!";
$all_css['blue']['label'] = "Deep blue";
$all_css['modern']['label'] = "Final..."; // default

$default_value = "modern"; // set the default value here

if (isset($_GET['change_css']) && $_GET['change_css'] != "") {
   
$_SESSION['css'] = $_GET['change_css'];
} else {
   
$_SESSION['css'] = (!isset($_SESSION['css'])) ? $default_value : $_SESSION['css'];
}
switch (
$_SESSION['css']) {
    case
"yellow":
   
$css_file = "home_geel.css";
    break;
    case
"blue":
   
$css_file = "home_blauw.css";
    break;
    default:
   
$css_file = "home_modern.css";
}
function
style_switcher() {
    global
$all_css;
   
$style_links = "Style switch: \n";
    foreach (
$all_css as $key => $val) {
        if (
$_SESSION['css'] != $key) {
           
$style_links .= "<a href=\"".$_SERVER['PHP_SELF']."?change_css=".$key."\">";
           
$style_links .= "<b>".$val['label']."</b></a>  \n";
        } else {
           
$style_links .= "<b>".$val['label']."</b>  \n";
        }
    }
    return
$style_links;
}
?>


<!-- EXAMPLE: place this inside your html header -->
<link href="/includes/<?php echo $css_file; ?>" rel="stylesheet" type="text/css">
<!-- place this code inside the body where you want to show the links -->
<?php echo style_switcher(); ?>



XDT Topsite (Gold v1.0)
Categories : Databases, CSS, PHP, HTML and PHP, Sessions
Print out array key => value in colored HTML
Categories : PHP, Arrays, HTML and PHP
Form Submission Using Array's
Categories : PHP, HTML and PHP, Beginner Guides, Arrays
Parse string to find sub-string between two arbitrary strings
Categories : PHP, Strings, HTML and PHP, Arrays
AITSH Statistics
Categories : Complete Programs, Databases, HTML and PHP, Sessions, PHP
PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions
Simple PHP control CSS Calendar
Categories : PHP, HTML and PHP, Calendar, Date Time, CSS
Parsing html tags with php. Get an array from this function
Categories : PHP, HTML and PHP, Arrays, Tag Extractors
Simple script to passing persistent and growing array between recalls of one page (manipulate little stack).
Categories : Arrays, Global Variables, PHP, HTML and PHP, Variables
Kewl Date Example
Categories : PHP, HTML and PHP, Date Time, CSS, Beginner Guides
Dynamic CSS generation for multiple website colouring schemes.
Categories : PHP, CSS, HTML and PHP
dynamic table columns
Categories : PHP, HTML and PHP, Arrays, Databases, MySQL
PHP alternating the colors of table rows with style.
Categories : PHP, HTML and PHP, CSS
navbar.php3 - Dynamic hyperlinked navigation bars
Categories : HTML and PHP, Arrays, PHP, Complete Programs
Select with current month
Categories : PHP, HTML and PHP, Date Time, Arrays