2016-08-24 36 views
1

我正在從我的數據庫中檢索帖子,但我希望<div class="welcome-text"><strong>This is my second output</strong> </div>顯示在檢索的表格下方,但其始終顯示在上方。有沒有什麼辦法可以解決這個問題:如何訂購html和php內容的顯示

<?php 
while($posts_row = mysql_fetch_assoc($posts_result)) 
{ 
    echo ' 
    <tr class="topic-post"> 
      <td class="user-post">' . $posts_row['user_name'] . '<br/>' . date('d-m-Y H:i', strtotime($posts_row['post_date'])) . '</td> 
      <td class="post-content">' . htmlentities(stripslashes($posts_row['post_content'])) . '</td> 
      </tr> 

      '; 
} 
?> 
<div class="welcome-text"><strong>This is my second output</strong> </div> 

enter image description here

將很快使用的mysqli或製備的聲明,因爲我得到這個固定

+1

你能顯示完整的HTML,我想你不關閉表'歡迎-text'前 – AgeDeO

+0

那是真的,我沒有在合適的位置關閉表。謝謝 – Mysterio4

+0

提示:驗證您的HTML輸出有助於發現此類錯誤。 https://validator.w3.org/ – CBroe

回答

2

您開放div標籤前din't關閉表標籤。

<table> 
<?php 
    while($posts_row = mysql_fetch_assoc($posts_result)) 
    { 
     echo ' 
     <tr class="topic-post"> 
       <td class="user-post">' . $posts_row['user_name'] . '<br/>' . date('d-m-Y H:i', strtotime($posts_row['post_date'])) . '</td> 
       <td class="post-content">' . htmlentities(stripslashes($posts_row['post_content'])) . '</td> 
       </tr> 

       '; 
    } 
    ?> 
</table> 
    <div class="welcome-text"><strong>This is my second output</strong> </div> 
+0

現在它工作的很好,我應該在div之前關閉表 – Mysterio4