Dinamic css design

Started on the old forum in April 2011 · view the original in the archive · old links redirect here

2 replies · 1,109 views · started 15 years ago · 1 min read

2 participants
arnage Lead · 811 posts #1

algorithm:

$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:

<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:

<link rel="stylesheet" type="text/css" href="./folder/'.$css.'.css"/>
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
GumSlone Administrator Principal · 1,690 posts #2

you could do the php part like this,

$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

External image (may be gone)

arnage Lead · 811 posts #3

Well i guess that elegant code comes with the experience. Maybe im too obsessed with checking... 🤣

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close