这是php或缓存的故障吗


Is it a fault with php or cache

我有一个简单的测试,但我一辈子都无法让它发挥作用。事实上,我真是疯了。就好像图像和php有问题一样。我只能显示一张图片,不能显示更多。脚本显示正确。如果有我不知道的修复或缓存问题,请告诉我。谢谢以下是两部分代码:php用于计算服务器端,html用于显示这两个图像。

php

$result = mysqli_query($mydb, "SELECT user FROM `table` ORDER BY RAND() LIMIT 0, 2");
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)){
echo $row[0]; // I use this echo to prove that the user name shows for [0]
echo $row[1]; // I use this echo to prove that the user name shows for [1]
$src1 = 'thumb/'.$row[0].'img1.jpg'; // directory of file
$src2 = 'thumb/'.$row[1].'img1.jpg'; // directory of file 
}

html显示img

<!doctype html>
<html>
    <body>
        <table>
          <tr>
          <td>
                <img src="<?php echo $src1; ?>" id="srca" alt="srcerra" />
                <img src="<?php echo $src2; ?>" id="srcb" alt="srcerrb" />
          </td>
          </tr>
       </table>
    </body>
</html>

第一张图片显示很好,第二张图片只是给了我img alt(srcerrb)。每个文件名的用户名不同。

试一下,看看你是否能得到和我一样的结果。镜像目录是完美的,经过了测试。干杯

您似乎混淆了行和列。查询返回两行,但每行只有一列,即$row[0]。代码应该是这样的:

$result = mysqli_query($mydb, "SELECT user FROM `table` ORDER BY RAND() LIMIT 0, 2");
$row = mysqli_fetch_row($result); // get first row
$src1 = 'thumb/'.$row[0].'img1.jpg';
$row = mysqli_fetch_row($result); // get second row
$src2 = 'thumb/'.$row[0].'img1.jpg';