fireice87 Posted April 30, 2007 Share Posted April 30, 2007 Hey iv got a script that can add colour codes to a data base and a script that pulls them out again This code works fine it collects the data from the table and puts it into variables $conn = @mysql_connect( "localhost", "user", "pass") or die ("could not connect to mysql"); #Connect to mysql $rs = @mysql_select_db( "db", $conn ) or die ("Could not select database"); #select database $sql = "Select `Backgroundcolour`,`Backgroundimage`,`Bordercolour`,`Borderthickness`,`Headingtextcolour`,`Headingtextsize`,`Maintextcolour`,`Maintextsize` FROM style_$user where id=1"; $result= @mysql_query($sql, $conn ) or die(" Could not add style facts"); while($row = mysql_fetch_row($result)) { $Backgroundcolour = $row[0]; $Backgroundimage = $row[1]; $Bordercolour = $row[2]; $Borderthickness = $row[3]; $Headingtextcolour = $row[4]; $Headingtextsize = $row[5]; $Maintextcolour = $row[6]; $Maintextsize = $row[7]; } But this bit of code doesnt work (in css) #Profile { height: 700px; width: 920px; background-color: <?php $Backgroundcolour ?> ; } what happens is the page display correctly(no errors) but with out any attention to the colours the variables are holding is there a way to do what im trying or am i on the wrong tracks with this? thanks Quote Link to comment https://forums.phpfreaks.com/topic/49333-solved-using-php-variables-in-css-is-it-possiple/ Share on other sites More sharing options...
arianhojat Posted April 30, 2007 Share Posted April 30, 2007 <?php echo $Backgroundcolour; ?> maybe print the color, u just declared the variable? u can inslude the css in the .php whioch is what i assuem you are doing, or include .css files to be parsed by php on your web server (google it) Quote Link to comment https://forums.phpfreaks.com/topic/49333-solved-using-php-variables-in-css-is-it-possiple/#findComment-241751 Share on other sites More sharing options...
papaface Posted April 30, 2007 Share Posted April 30, 2007 You need to echo it: background-color: <?php echo $Backgroundcolour; ?> ; Quote Link to comment https://forums.phpfreaks.com/topic/49333-solved-using-php-variables-in-css-is-it-possiple/#findComment-241753 Share on other sites More sharing options...
The Little Guy Posted April 30, 2007 Share Posted April 30, 2007 you will need to have the CSS placed in the head of your HTML, then the file needs to be saved as a php file, then you can change the CSS with PHP. Quote Link to comment https://forums.phpfreaks.com/topic/49333-solved-using-php-variables-in-css-is-it-possiple/#findComment-241756 Share on other sites More sharing options...
fireice87 Posted April 30, 2007 Author Share Posted April 30, 2007 Hey thanks alot i did need to just add echo and it all works thanks, yeah the css styling rules on in the head of a php document thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/49333-solved-using-php-variables-in-css-is-it-possiple/#findComment-241776 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.