oops, forgot a /
must be (of course)
the
[...]should be a placeholder for
fancy other code here if needed.
I take this as
hey, slow down, I'm a beginner
To let the user choose the values of $styleAnchor, $styleAnchorHover & $imgSrc you have to show them the possibilities and your script must react on the choice. Somewhere you have to store that information as long as this user stays on your site.
I will keep this very simple. Let's say the possible skins are stored within an array. Starting with only one skin and how to access the values
Code: Select all
<?php $skin = array(); // <- supresses a warning
$skin['anchor'] = 'color: red'
$skin['hover'] = 'color: green';
$skin['image'] = 'imgs/picA.png';
echo '<pre>'; print_r($skin); echo '</pre>'; // take a closer look at the output of this
echo 'anchor is: ', $skin['anchor'], '<br />';
echo 'hover is: ', $skin['hover'], '<br />';
echo 'image is: ', $skin['image'], '<br />';
?>
the array is the same if you create it this way
Code: Select all
<?php
$skin = array(
'anchor' => 'color: red',
'hover' => 'color: green',
'image' => 'imgs/picA.png'
);
echo '<pre>'; print_r($skin); echo '</pre>'; // compare both print_r outputs
?>
but storing only one skin is not that useful. Let's store more of them in another array.
Setting elements of an array is not limited to strings. You can assign a whole array to another array, creating a multi-dimensional array.
Code: Select all
<?php
$allSkins = array();
$allSkins['red theme'] = array(
'anchor' => 'color: red; text-decoration: none;', // styles changed a bit for later use
'hover' => 'color: red; text-decoration: underline;',
'image' => 'imgs/picA.png'
);
$allSkins['green theme'] = array(
'anchor' => 'color: green; text-decoration: none;',
'hover' => 'color: green; text-decoration: underline;',
'image' => 'imgs/picB.png'
);
$allSkins['blue theme'] = array(
'anchor' => 'color: blue; text-decoration: none;',
'hover' => 'color: blue; text-decoration: underline;',
'image' => 'imgs/picC.png'
);
// this time take a very close look at the output of ...
echo '<pre>'; print_r($allSkins); echo '</pre>';
// and now only as example accessing a specific element of each skin
echo $allSkins['red theme']['anchor'], '<br />';
echo $allSkins['green theme']['anchor'], '<br />';
echo $allSkins['blue theme']['anchor'], '<br />';
echo '<hr />';
/* read http://www.php.net/manual/en/control-st ... oreach.php
to learn more about the next construct
*/
foreach($allSkins as $skin)
echo $skin['anchor'], '<br />';
echo '<hr />';
// and now with names
foreach($allSkins as $name=>$skin)
echo $name, ' sets anchor style to ', $skin['anchor'], '<br />';
?>
if you did not try the examples and examine the output (at least of print_r) now would be a good time to start

so much on arrays right now. See also:
http://www.php.net/manual/en/language.types.array.php
...to be continued...