【发布时间】:2022-01-03 01:30:33
【问题描述】:
这是我到目前为止所拥有的,但它不起作用。这是我的 CSS:
background-image: url("upload/blog/'.$row["urlImg"].'");
这里是完整的代码:
<?php
$stmt = $db->query
( 'SELECT blog.postID, blog.postTitle, blog.postSlug, blog.postDesc, blog.urlImg, blog.postTags, blog.postDate
FROM blog, blog_post_cats
WHERE blog.postID = blog_post_cats.postID AND blog_post_cats.catID = 4 ORDER BY postID DESC LIMIT 1'
);
while($row = $stmt->fetch())
{
echo '<article style="background-image: url(upload/blog/'.$row['urlImg'].'" );"> ';
}
?>
这个 PHP echo 不起作用。
clicke to view output screenshot ,the blank space is the error ,others are url images
【问题讨论】:
-
您忘记添加代码了吗? ???请edit您的问题。
-
我认为问题在于不正确地转义引号。
-
您需要编辑您的问题以显示您如何获得
$row["urlImg"]如果它返回空白,那么查询(假设因为您使用$row)可能返回空白或者您可能正在获取它错了 -
第一个代码 sn-p 和“完整”代码彼此不同。不清楚是什么。
-
你能告诉我们
html“不起作用”时显示在输出上吗
标签: php css background-image