How can I use PHP code in a CSS file -


i want find image source mysql database , assign css style. changed .css extension .php.

it work xampp , runs want, when uploaded code in cpanel didn't work correctly.

i used code in css file:

top of page:

<?php include '../connections/base.php'; ?>  <?php header("content-type: text/css; charset: utf-8"); ?> 

some styles:

.box {     overflow: hidden;     display:block;     border:4px solid #171717;     position:absolute;     cursor: pointer;     float:left;     display: inline-block;     zoom: 1;     background:url(<?php          $query = "select imape_path mytable number='5' limit 1";         //echo $query;         if ($result = $mysqli->query($query)) {             while ($row = $result->fetch_assoc()) {                 echo $row['imape_path'];             }         }  ?>) no-repeat; } 

how can fix problem?

personally, not think right problem address.

the whole point in separating markup , styles simplify things. see little value in separating rigidly have mix css, php , sql instead (you moved same problem elsewhere).

my suggestion configure .box's background using inline css in html page , inject url other value:

<div class="box" style="background: url('<?php ... ?>')">...</div> 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -