为什么blockquote标签在PHP循环中不起作用?

时间:2019-05-03 18:23:14

标签: php while-loop imgur

我正在从数据库中返回数据,除图像外,所有数据均有效,由于某种原因,blockquote标记仅打印在第一行,我使用embed.js返回Imgur照片和.gifs < / p>

html

<script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>

php

<h1>Fotos e gifs</h1>
<?php
include_once("config.php");
$result = mysqli_query($mysqli, "SELECT * FROM posts ORDER BY codigo DESC");
while($res = mysqli_fetch_array($result)) {
    echo "<h3>".$res['titulo']."</h3>";
    echo "<blockquote class='imgur-embed-pub' lang='en' data-id='".$res['link_imagem']."'></blockquote>";
    echo "<hr>";
}   
?>

这是正在发生的事情,我的数据库。

enter image description here

1 个答案:

答案 0 :(得分:0)

我为此找到了解决方案,由于某种原因,每个脚本都支持一个blockquote,我只是在while循环中添加到script标签,如下所示:

while($res = mysqli_fetch_array($result)) {
    echo "<h3>".$res['titulo']."</h3>";
    echo "<blockquote class='imgur-embed-pub' data-id='".$res['link_imagem']."'></blockquote>"."<script async src='//s.imgur.com/min/embed.js' charset='utf-8'></script>";
    echo "<p>".$res['conteudo']."</p>";
    echo "<hr>";
}