![](/img/trans.png)
[英]change the css class based on the php/mysql query output values in a table
[英]change css variables based on values in mysql database
我有一个css文件heredoc作为php,定义了3个值
<?php header("Content-type: text/css");
$clabel = '#384DA0';
$cbackground = '#89A1BA';
$cfont = '#000000';
?>
我想基于mysql表中的值更改这些变量。 如果不存在默认值,则保留默认值。
我将如何去做?
解冻
在使用Heredoc之前进行设置:
$request = //do some database request here;
$clabel = $request['clabel'] ? $request['clabel'] : 'default value';
$myCSS = <<<EOT
.someclass{color: $clabel;}
EOT;
根据我对heredocs的(基本)知识,应使用正确分配的变量来解析您的CSS。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.