Dinamic css design

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Dinamic css design

    algorithm:

    PHP Code:
    $css = isset($_GET['css']) ? trim($_GET['css']) : '';

    $thecss = array('one''two''tree''four'); // Just letter names

    if (!isset($css) || empty($css)) {
    $css 'one';
    }
    elseif (isset(
    $css) && array_key_exists($css$thecss)) {
    $css $thecss[$css];
    } else {
    if (!empty(
    $css) && !in_array($css$csses)) { exit; }

    interface:

    Code:
    <form method="get" action="./index.php">
    <p>
    <select name="css">
    <option value="one">one</option>
    <option value="two">two</option>
    <option value="tree">tree</option>
    <option value="four">four</option>
    </select>
    <input type="submit" value="Ok"/>
    </p>
    </form>
    usage:

    Code:
    <link rel="stylesheet" type="text/css" href="./folder/'.$css.'.css"/>
    Last edited by arnage; 20.04.11, 20:38.
    <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

    #2
    you could do the php part like this,
    PHP Code:
    $css = isset($_GET['css']) ? trim($_GET['css']) : ''
    $thecss = array('one''two''tree''four'); // Just letter names
    if (in_array($css$thecss)==false) {
        
    $css 'one';

    Advertise your mobile site for FREE with AdTwirl

    Comment


      #3
      Well i guess that elegant code comes with the experience. Maybe im too obsessed with checking...
      <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

      Comment

      Working...
      X