我有一个奇怪的错误,我知道我发布了很多代码,但是,我真的不明白我做错了什么,所以我决定将所有代码放在这里与我的问题相关。
我还评论了我的代码,以便轻松理解上下文。
问题是:
我从数据库中提取我的新闻信息,而我的图像有问题,只有第一篇文章的图片,即最近的新闻,正在出现,其他人不会出现。
但是,如果我删除了我引用的代码,例如 FROM HERE * ** TO HERE * ,则图片会正确显示。
有人意识到为什么会在这段代码中发生这种情况导致我的新闻图片没有出现?
<div id="content">
<h1>News</h1>
<?php
//first I read my news
$readNews = $pdo->prepare("SELECT * FROM news WHERE status = 1 ORDER BY date DESC LIMIT 0,4");
$readNews->execute();
//while exist news I want to read category of that news, and show news info in my article
while ($readNewsResult = $readNews->fetch(PDO::FETCH_ASSOC))
{
$readCat= $pdo->prepare("SELECT * FROM categories , news WHERE id_cat = ?");
$readCat->bindValue(1,$readNewsResult['category']);
$readCat->execute();
$resultReadCat = $readCat->fetch(PDO::FETCH_ASSOC);
//I show news info in my article
echo '<article class="loop-news">';
echo '<img src="'.$path.$readNewsResult['thumb'].'" />';
echo '<h2><a href="#">'.$readNewsResult['title'].'</a><br /></h2>';
echo '<span>'.$resultNewsResult['date'].'</span>';
echo '<p>'.$readNewsResult['content'].'<a id="'.$readNewsResult['id_not'].'" class="fancybox" href="#show'.$readNewsResult['id_not'].'">See more</a></p>';
//I repeat my news info to show inside fancybox
echo '<div class="show-container">';
echo '<div id="show'.$readNewsResult['id_news'].'">';
echo '<h2>'.$readNewsResult['title'].'</h2>';
echo '<span>'.$resultNewsResult['date'].'</span>';
echo '<img src="'.$path.$readNewsResult['thumb'].'" />';
echo '<p>'.$readNewsResult['content'].'</p>';
//******************FROM HERE***************************/
//I read my table links_news to see if news that is reading have links associated
$readLinks = $pdo->prepare("SELECT * FROM links_news WHERE news_id = ?");
$readLinks->bindValue(1,$readNewsResult['id_news']);
$readLinks->execute();
//if current reading news have links it will show on my links div
echo '<div class="links">';
echo '<h3>Relative Links:</h3>';
echo '<ul class="links1">';
while ($readLinksResult = $readLinks->fetch(PDO::FETCH_ASSOC))
{
echo '<li> <a href="'.$path.$readLinksResult['link'].'">'.$readLinksResult['link'].'</a></li>';
}
echo '</ul>';
echo '</div>';<!-- close class links-->
//****************TO HERE*******************/
echo '</div>';<!-- close class show -->
echo '</div>';<!-- close class show-container-->
echo '</article>';
}
?>
</div>