我的PHP代码如下 回显图像仅显示其缩略图
<?php
if(isset($_SESSION['user_id'])){
$userid = $_SESSION['user_id'] ;
$query = "SELECT img FROM user where iduser='{$userid}' LIMIT 1 ";
$result_set = mysqli_query($connection,$query);
while($row = mysqli_fetch_assoc($result_set)){
echo $row['img'];
if(is_null($row['img'])){
echo '<img src="assets/images/fuser.png" class="img-responsive img-thumbnail" style="height:256px;width:256px">';
}else{
echo '<img src="assets/images/"'.$row['img'].'" class="img-responsive img-thumbnail" style="height:256px;width:256px">';
}
}
}
?>
我的图片显示如下 https://imgur.com/a/uXcdytz
答案 0 :(得分:1)
你回应的html格式不正确:
echo '<img src="assets/images/"'.$row['img'].'" class="img-responsive img-thumbnail" style="height:256px;width:256px">';
对于$row['img']
image1.jpg
,您的代码将回复此信息:
<img src="assets/images/"image1.jpg" class="img-responsive img-thumbnail" style="height:256px;width:256px">
src
属性中有一个额外的不必要引用,因此图片src
目标将不存在,您的回应应该是(在{{1}之后删除"
之后}):
images/
还要确保您的php文件位于echo '<img src="assets/images/'.$row['img'].'" class="img-responsive img-thumbnail" style="height:256px;width:256px">';
文件夹中。