Re: Creating a Dynamic PHP/CSS Page (newbie design question)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shawn McKenzie wrote:
> cool@xxxxxxxxxxxxxxxx wrote:
>> Hi Folks,
>>
>> My goal: is to have a template form to control css styles, where the
>> user fills out choices in a template form page and the results might get
>> stored in a MysQL prefs table.
>>
>> But I guess you can't have php mixed with .CSS page ... so is the best
>> way to do this like: ...?
>>
>> - set a a normal mystyle.css style sheet with no php but with all
>> possible choices
>>
>> - then - on the css prefs form page you might have choices like:
>>
>> fontsize = small or med or big etc. then you might store the 'actual'
>> css name (on the real css style sheet) associated with the choice like :
>> style = "HEADER1" or whatever based on the choice
>>
>>
>> then let's say I have a page:
>>
>> mypage.php
>>
>> that links to a css style sheet:
>>
>> mystyle.css
>>
>> - then the php page might use it like:
>>
>> class = "<?php echo $thischoice; ?>" for "HEADER1"
>>
>> Q: Is that the best way to setup dynamic css choices using php?
>>
>> Any comments would be appreciated - dave
>>
>>
>> Thanks,
>> cool@xxxxxxxxxxxxxxxx
>>
> 
> Maybe setup your table like this:
> 
> selector	style		value
> -------------------------------------
> HEADER1		font-size	small
> HEADER1		color		black
> etc...
> 
> Then have a PHP page (user_styles.php) that queries the DB for the
> styles and echoes them:
> 
> $result = query("SELECT * from user_styles WHERE userid = $userid");
> 
> while($row = fetch_assoc($result)) {
>     echo $row['selector']." { ".$row['style'].": ".$row['value']." }\n";
> }
> 
> Then just link the PHP page as a stylesheet in your HTML:
> 
> <link rel="stylesheet" href="user_styles.php" type="text/css" />
> 
> 
> 

Obviously you'd also want the userid and most likely a PK in the table
also :-)

id	userid	selector	style		value
-----------------------------------------------------

And also probably what Ash said:

header("Content-Type: text/css");

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux