我想通過php文件顯示css。大多數事情都很好,直到我想要從數據庫中顯示圖像。在源代碼中,它確實接受來自數據庫的值,但不顯示圖像。如果我使用常規的CSS,圖像將顯示。任何想法將不勝感激。這是代碼。css在php文件中使用時不顯示圖像
header("Content-type: text/css");
include('database connect info here');
include('/session info here');
sec_session_start();
$numm =$_SESSION['memid'];
$query = $mysqli->prepare("SELECT * FROM preff WHERE memid = :memid");
$query->bindParam(':memid', $numm);
$query->execute();
$row = $query->fetch(PDO::FETCH_ASSOC);
$bgimage = $row['backgroundimage'];
?>
body{
background-image:url('<?=$bgimage?>') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
再次感謝。
我們可以將這個=$bgimage?>更改爲<?php echo $ bgimage; ?>並嘗試 – Satya
它是否與您的php文件位於相同的文件夾中? –
你能提供輸出的源代碼嗎? – chris85