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 : Dynamic CSS generation for multiple website colouring schemes.
Categories : PHP, CSS, HTML and PHP Click here to Update Your Picture
Ioannis Cherouvim
Date : Apr 16th 2005
Grade : 4 of 5 (graded 5 times)
Viewed : 13164
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Ioannis Cherouvim
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

You can view a working example at : http://www.weberdev.com/examples/4133_index.php?color=255

<?php

//***************************************************************
//** title  : Dynamic CSS generation for multiple website colouring schemes.
//**
//** file   : style.php
//**
//** story  : Ever wanted to provide your user with buttons where from
//**          he could change the colour scheme of the page ? Or even
//**          provide deferent colour scheme each day, randomly or
//**          depending on your mood (??). This script will show you
//**          the basic idea of how to provide a php script which
//**          will generate CSS on the fly.
//**         
//**          The idea is that given a single 24bit number representing
//**          3 8bit colour values (RGB) we can generate 10 shades based
//**          on that desired colour. Then by using those 10 shades
//**          we ensure that the site will have a uniform feel.
//**         
//**
//** author : Ioannis Cherouvim
//** e-mail : morales@hack.gr
//** date   : 2005-03-22
//***************************************************************

    //the 24bit value representing the desired colour
   
$get_color = (isset($_GET["color"]) ? $_GET["color"] : "");

   
//some basic algorithm to extract the the RGB values
   
$r = ($get_color % 256)/2;
   
$g = (($get_color >> 8) % 256)/2;
   
$b = ((($get_color >> 8) >> 8) % 256)/2;

   
//make gradients
   
$c = appendGrads(doGrad($r), doGrad($g), doGrad($b));

   
//simple algorithm to convert a 16bit dec to hex
   
function dec2hex16bit($dec) {
       
$digits = "0123456789ABCDEF";
        return (
$dec>-1 && $dec<256?$digits[$dec / 16].$digits[$dec % 16]:"XX");
    }

   
//produces 10 shades of a 8bit value
   
function doGrad($c) {
        for (
$i = 0; $i < 10; $i++) $grad[$i] = dec2hex16bit(floor($c + ($i*(255-$c)/12)));
        return
$grad;
    }

   
//concatenates the 8bit RGB hex values into a 24bit one
   
function appendGrads($r, $g, $b) {
        for (
$i = 0; $i < 10; $i++) $grad[$i] = $r[$i].$g[$i].$b[$i];
        return
$grad;
    }

?>
body {
    background-color: #<?php echo $c[9]?>;
    margin: 50px 50px 50px 50px;
}

.table1 {
    border: solid 2px #<?php echo $c[2]?>;
    background-color: #<?php echo $c[6]?>;
    width: 100%;
    height: 100%;
    text-align: center;
}
.table1 th {
    font-family: Verdana, Sans-Serif;
    font-size: 18px;
    letter-spacing: 3px;
    color: #<?php echo $c[0]?>;
    border: solid 2px #<?php echo $c[4]?>;
    background-color: #<?php echo $c[8]?>;
    height: 50px;
}
.table1 td {
    border: solid 2px #<?php echo $c[4]?>;
    background-color: #<?php echo $c[7]?>;
    text-align: center;
    width: 100%;
}

a:link, a:visited, a:active {
    font-family: Arial, Sans-Serif;
    font-size: 16px;
    background-color: #<?php echo $c[6]?>;
    color: #<?php echo $c[0]?>;
    border: solid 2px #<?php echo $c[4]?>;
    text-decoration: none;
    font-weight: bold;
    margin: 10px 10px 10px 10px;
    padding: 10px 10px 10px 10px;
}

a:hover {
    border: solid 2px #<?php echo $c[6]?>;
    background-color: #<?php echo $c[9]?>;
}




<?php

//***************************************************************
//** title  : Dynamic CSS generation for multiple website colouring schemes.
//**
//** file   : index.php. an example use of the style.php above
//**
//** author : Ioannis Cherouvim
//** e-mail : morales@hack.gr
//** date   : 2005-03-22
//***************************************************************

   
$self = $_SERVER['PHP_SELF'];

    echo
"<html><head><style type='text/css'>";
    include
"style.php";
    echo
"</style><title>Dynamic CSS</title></head>";

    echo
"<body>";
    echo
"<table class='table1'>";
    echo
"<tr><th colspan='2'>Dynamic CSS - Click on buttons to change colors</th></tr>";
    echo
"<tr><td>";

    echo
"<a href='$self?color=255'>Red</a>";
    echo
"<a href='$self?color=13566115'>Purple</a>";
    echo
"<a href='$self?color=1032208'>Green</a>";
    echo
"<a href='$self?color=16711680'>Blue</a>";
    echo
"<a href='$self?color=65536'>Gray</a>";
    echo
"<a href='$self?color=10181680'>Navy</a>";
    echo
"<a href='$self?color=".mt_rand(0, 16777216)."'>Random</a>";

    echo
"</td></tr></table>";
    echo
"</body></html>";
?>



Simple PHP control CSS Calendar
Categories : PHP, HTML and PHP, Calendar, Date Time, CSS
XDT Topsite (Gold v1.0)
Categories : Databases, CSS, PHP, HTML and PHP, Sessions
Kewl Date Example
Categories : PHP, HTML and PHP, Date Time, CSS, Beginner Guides
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
CSS style switcher
Categories : PHP, CSS, HTML and PHP, Arrays, Sessions
PHP alternating the colors of table rows with style.
Categories : PHP, HTML and PHP, CSS
background music script for random notes in a frame
Categories : PHP, Content Management, HTML and PHP
Dynamic Calendar in PHP, Javascript and HTML.
Categories : PHP, Java Script, HTML and PHP, Calendar
Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used.
Categories : HTML and PHP, PHP, Date Time
The Nearly Perfect Contact Us Form
Categories : PHP, Form Processing, HTML and PHP
Parse html (title :: meta)
Categories : PHP, HTML and PHP, Regexps
If you want to create select buttons featuring current date this example will show you how...
Categories : Date Time, HTML and PHP, PHP
Dynamic Page
Categories : Frameworks, PHP, HTML and PHP
Simple Generic Drop Down List Function
Categories : PHP, HTML and PHP, Functions
Class to build a select tag in html, useful to build select boxes from a data base
Categories : PHP, HTML and PHP, PHP Classes