Re: Using PHP to Generate a CSS Style Sheet
| From: | Justin French | Date: | Tue, 04 Mar 2003 12:53:24 +0000 |
| Subject: | Re: Using PHP to Generate a CSS Style Sheet | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138089@lists.php.net to get a copy of this message | ||
on 04/03/03 5:37 PM, Phillip S. Baker (phillip@freewolf.net) wrote:
> I would like to use PHP to make calls from a DB and generate a CSS file.
> Anyone have any ideas on doing this?
every day :)
PHP is some kind of programming language which is PARSED by PHP. The result
is a TEXT FILE of some description... yes, even a CSS file.
How to do it depends entirely on your database structure and what you want
to achieve.
But a quick example:
---
<?
$textColour = 'FF9900'; // a var you retrieved from a DB
$bgColour = 'white'; // a var you retrieved from a DB
?>
P { color: #<?=$textColour?>; }
BODY { background-color: #<?=$bgColour?>; }
---
> Will php commands executre from a .css file or is there a different way to
> do this??
.css files will not *automatically* be parsed by PHP, however you can force
them through with either a .htaccess file, or by editing apache's httpd.conf
file to suit.
this is my .htaccess file:
<Files dynamic.css>
ForceType application/x-httpd-php
</Files>
Or, you can just include() some CSS generated by PHP directly into your PHP
application, and it will just appear as part of the HTML source.
Justin French