Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.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
在PHP中打印图像 $fetch['img']的内容是什么?是图像名吗?如果这是您的代码应该工作的情况,只需检查您是否也保留了文件的扩展名,否则只需将其连接起来。_Php_Html - Fatal编程技术网

在PHP中打印图像 $fetch['img']的内容是什么?是图像名吗?如果这是您的代码应该工作的情况,只需检查您是否也保留了文件的扩展名,否则只需将其连接起来。

在PHP中打印图像 $fetch['img']的内容是什么?是图像名吗?如果这是您的代码应该工作的情况,只需检查您是否也保留了文件的扩展名,否则只需将其连接起来。,php,html,Php,Html,就像上面提到的@u nuts一样,您已经在回显一个值,因此您不需要在数据库中包含$fetch['img']是img字段的名称。“”width=“165”height=“165”>。“我想这样做,但我不知道语法问题是什么,也不知道结构会是什么。你已经在php中了,所以你不能用再次打开php标记。另外一件事我没有提到就更改了,它是width=“165”(双引号)到width='165'(单引号)。我这样做的原因是,我认为在双引号中包含单引号(两个都是有效的HTML)看起来更干净,而不是转义嵌套的双引

就像上面提到的@u nuts一样,您已经在回显一个值,因此您不需要在数据库中包含
$fetch['img']是img字段的名称。“”width=“165”height=“165”>。“我想这样做,但我不知道语法问题是什么,也不知道结构会是什么。你已经在php中了,所以你不能用
再次打开php标记。另外一件事我没有提到就更改了,它是
width=“165”
(双引号)到
width='165'
(单引号)。我这样做的原因是,我认为在双引号中包含单引号(两个都是有效的HTML)看起来更干净,而不是转义嵌套的双引号——尽管这两个双引号在PHP中都是100%有效的。所以我可以用
…“'width=\'165\”
来避开双引号()
<?php
if(ISSET($_POST['fecha'])){
    $query = mysqli_query($conn, "SELECT * FROM `fotos` ORDER BY `fecha` DESC") or die(mysqli_error());
    //$query = $conn->query("SELECT * FROM `fotos` order by fecha desc") or die(mysqli_errno()); (ORDENA POR FECHA)
    while($fetch = mysqli_fetch_array($query)){
      echo "<tr>
            <td>".$fetch['fecha']."</td>
            <td>".$fetch['nombre']."</td>
            <td>".$fetch['codigo']."</td>
            <td>".$fetch['correo']."</td>
            <td>".$fetch['img']."</td>
            <td>."<center><img src="<?php echo "upload/".$fetch['img']?>" width="165" height="165">."</center></td>
            <td><center><img src="<?php echo "upload/".$fetch['img']?>" width="165" height="165"></center></td>
        </tr>";
while($fetch = mysqli_fetch_array($query)){
    echo "<tr>
        <td>".$fetch['fecha']."</td>
        <td>".$fetch['nombre']."</td>
        <td>".$fetch['codigo']."</td>
        <td>".$fetch['correo']."</td>
        <td>".$fetch['img']."</td>
    </tr>";
}
<td>
    <center>
        <img src="<?php echo "upload/".$fetch['img']?>" width="165" height="165">
    </center>
</td>
echo "<tr>
<td>{$fetch['fecha']}</td>
<td>{$fetch['nombre']}</td>
<td>{$fetch['codigo']}</td>
<td>{$fetch['correo']}</td>
<td>{$fetch['img']}</td>

<td><center><img src='upload/{$fetch['img']}' width='165' height='165'></center></td>
<td><center><img src='upload/{$fetch['img']}' width='165' height='165'></center></td>
</tr>";
echo "<tr>
<td>".$fetch['fecha']."</td>
<td>".$fetch['nombre']."</td>
<td>".$fetch['codigo']."</td>
<td>".$fetch['correo']."</td>
<td>".$fetch['img']."</td>

<td><center><img src='upload/".$fetch['img']."' width='165' height='165'></center></td>
<td><center><img src='upload/".$fetch['img']."' width='165' height='165'></center></td>
</tr>";