So i read article on css-tricks.com˙(http://css-tricks.com/css-variables-with-php/) about PHP in CSS and I tried it myself. I'm having problem structuring it. To be specific, i'm using Sql to take image from database and use result as a background image. Like this:
<?php
header("Content-type: text/css; charset: UTF-8");
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("login", $con);
$result = mysql_query("SELECT * FROM users");
while($row = mysql_fetch_array($result))
{
?>
Then goes my css, i will just write needed ID:
#user {
background: url(../img/<?php echo $row['cover']; ?>) fixed;
}
And at the end, I close connection:
<?php
};
mysql_close($con);
?>
Everything works except css is outputted double, that is listed twice.Can anyone point the problem? Thanks.
$result =runecho mysql_num_rows($result)and tell us the output.coveras an array key...