我試圖用來自數據庫的內容填充我的文章。試圖在頁面中顯示相同的內容,也在fancybox中
我有我的文章與標題,圖像,日期,內容和鏈接(閱讀更多)打開fancybox將顯示本文相同的內容,但在fancybox。
因此,我有我的div id="show-container"
,它對應於在fancybox中顯示內容的div。
這個div有顯示:無在CSS中,當與#show HREF和class =「的fancybox」鏈接的用戶點擊,在這裏它僅出現:
<a class="fancybox" href="#show">Read more</a>
但我想表現出同樣的fancybox中的內容,所以我填寫這個「表演」div與我在文章中的相同信息。
我的文章工作正常,每篇文章都有正確的名稱,圖片和內容。
但是當我點擊打開每篇文章的fancybox所有fancyboxs 具有相同的內容,這是我的第一篇文章的內容。
任何人都知道我可以解決這個問題嗎?
$readPost = $pdo->prepare("SELECT * FROM posts ORDER BY date DESC LIMIT 0,4");
$readPost->execute();
$folder = '../images/';
while ($readPostResult = $readPost->fetch(PDO::FETCH_ASSOC))
{
echo '<article id="loop-news">';
echo '<img src="'.$folder.$readPostResult['thumb'].'" title="'.$readPostResult['title'].'"/>';
echo '<h2>';
echo '<a href="#show" class="x" >'.$readPostResult['title'].'</a><br />';
echo '</h2>';
echo '<p>'.$readPostResult['content'].'<a class="fancybox" href="#show">Read more</a></p>';
echo '<div id="show-container">';
echo '<div id="show">';
echo '<h2>'.$readPostResult['title'].'</h2>';
echo '<br />';
echo '<img src="'.$folder.$readPostResult['thumb'].'" title="'.$readPostResult['title'].'"/>';
echo '<p>'.$readPostResult['content'].'<br /></p>';
echo '<a class="button" href="index.html">Back</a>';
echo '</div>';
echo '</div>';
echo '</article>';
}
?>
我想我需要傳遞的每個消息的ID,當我在A HREF點擊:
echo '<p>'.$readPostResult['content'].'<a class="fancybox" href="#show">Read more</a></p>';
你知不知道我怎樣才能做到這一點?因爲我已經在我的鏈接中使用「#show#」來打開fancybox ..
謝謝你的回答,但問題仍然存在! – OzzC
謝謝你MYoussef的主要問題是真的! :) – OzzC