Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自dB的图像调用正在使用PHP调用迭代两次_Php_Mysqli - Fatal编程技术网

来自dB的图像调用正在使用PHP调用迭代两次

来自dB的图像调用正在使用PHP调用迭代两次,php,mysqli,Php,Mysqli,我正在做一些我已经做过很多次的相对简单的事情,但出于某种原因,这让我感到悲伤。我需要从db调用以下图像: $ViewQuery = "SELECT * FROM users ORDER BY last_name asc;"; $Execute = mysqli_query($con, $ViewQuery); while($DataRows = mysqli_fetch_array($Execute)) { $profile_pic = $DataRow

我正在做一些我已经做过很多次的相对简单的事情,但出于某种原因,这让我感到悲伤。我需要从db调用以下图像:

    $ViewQuery = "SELECT * FROM users ORDER BY last_name asc;";
    $Execute = mysqli_query($con, $ViewQuery);

    while($DataRows = mysqli_fetch_array($Execute)) {
        $profile_pic = $DataRows["profile_pic"];
?>
然后下面的代码将其调用到前端

<img src="../assets/images/profile_pics/<?php 
   echo htmlentities($profile_pic); 
?>" width="50px" height="50px">
<?php } ?>

它对每一个图像调用都这样做……有人能解释一下为什么会发生这种情况吗?就像我说的,这段代码在别处&工作正常。任何帮助都将不胜感激

并不是说有人会说废话……好吧,至少没有我那么多,但我对此修修补补了太久,所以我会回答我自己的问题

我必须从以下位置更改我的呼叫:

src="../assets/images/profile_pics/assets/images/profile_pics/defaults/head_emerald.png"
“width=“50px”height=“50px”>
为此:

<img src="../assets/images/profile_pics/<?php echo htmlentities($profile_pic); ?>" width="50px" height="50px">
“width=“50px”height=“50px”>

Buggy古怪…就像我说的,在同一文件夹的另一个页面上的相同代码不需要,而这个页面需要

在调试器中转储或查看$profile_pic,应该是调试的第一步。你说它在“其他地方”工作-基本路径在这两个地方是相同的吗?否则,相对引用“./assets…”将把它带到另一个地方。我希望它能这么简单。文件路径是正确的,当然硬编码(我做了检查)工作正常。问题是它重复了../assets/images/profile_pics两次。我想你调用$Execute两次,从初始化到抓取我不这么认为-但我愿意尝试任何东西,我将前两个语句组合在一起,得到相同的结果。这太奇怪了。。。
<img src="../<?php echo htmlentities($profile_pic); ?>" width="50px" height="50px">