我试图像这样显示图像
<?php
$displaymyavatar="SELECT * FROM avatars INNER JOIN users ON avatars.users_id=users.id WHERE username='$login_session'";
$result_set=mysqli_query($db,$displaymyavatar);
while($row=mysqli_fetch_array($result_set)){?>
<img class="avatar" src='<?=$_SERVER['HTTP_REFERER'] . $row['image_file'];?>' alt="">
<?php };?>
我以为我找到了解决方案here,但图片没有显示。图像上传到文件夹&#34;上传&#34;
答案 0 :(得分:1)
相关链接是否适合您?如果是这样,您应该能够使用以下代码段。
<?php
$displaymyavatar="SELECT * FROM avatars INNER JOIN users ON avatars.users_id=users.id WHERE username='$login_session'";
$result_set=mysqli_query($db,$displaymyavatar);
while($row=mysqli_fetch_array($result_set)){ ?>
<img class="avatar" src="./<?php echo $row['image_file']; ?>" alt="">
<?php };?>
答案 1 :(得分:1)
您可以使用foreach循环
<?php foreach ($result_set as $key => $r): ?>
<img src="<?php echo $r['image_file'] ?>" />
<?php endforeach ?>
答案 2 :(得分:0)
这有效:
<?php
$displaymyavatar="SELECT * FROM avatars INNER JOIN users ON avatars.users_id=users.id WHERE username='marydoe'";
$result_set=mysqli_query($db,$displaymyavatar);
while($row=mysqli_fetch_array($result_set)){?>
<img class="avatar" src="core/<?php echo $row['image_file'] ?>" />
<?php };?>