开发者

PHP & CSS Output Problem

How do I set this up so that I can manipulate $backgroundcolor = "#00FFFF"; on another开发者_如何学Python .php file?

Initially I just want to be able to change the value of the $backgroundcolor ="#00FFFF"; From another form that is hrefed to this form (style.php) based on user input.

I Tried this on this form so that I could hopefully give $backgroundcolor different values: $backgroundcolor = " ";

Then I used another .php form that is hrefed to this style.php script to call $backgroundcolor ="some different hex color with no results";

In fact all I saw was the output of the value #0033FF, but I don't want the output, I want the new value #0033FF to be the background color?

<?php header("Content-type: text/css"); 
$backgroundcolor = "#00FFFF ";
$textcolor = " #0033FF";
?>
body {
 background:<?php  echo $backgroundcolor?>;
 color:<?php echo $textcolor?>;
}


You could use sessions, cookies, databases.

What you are trying to do is to persist some data through requests.

You have to store the background & text color somewhere, at your convenience.


Use this on the php side:

The idea is to get all the css and php code setup like this:

$backgroundcolor = $_REQUEST["backgroundcolor"];

background-color:$backgroundcolor;

Where background-color: will give you the color of the background in traditional CSS, we will use this with a variable, in this case $backgroundcolor;

On the html side we will have a form like this:

<select name = "backgroundcolor">
<option value = "#000000">Black</option>
<!-- And all we have to do is add multiple options for the different color values      
and the php script will do the rest after the user has selected 
the color he or she wants, done-->


#heredoc
$theStyle = <<<HERE
"border-width:$borderSize$sizeType;
background-color:$backgroundcolor;
color:$fontcolor;
border-style:$borderStyle;
border-color:green"
HERE;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜