2016-08-24 30 views
1

私のデータベースから投稿を取得していますが、<div class="welcome-text"><strong>This is my second output</strong> </div>を検索したテーブルの下に表示したいのですが、常に上に表示します。私はこの問題を解決することができますどのような方法があります:私は、これはあなたが開いているdivタグの前に近くのテーブルタグをdin'thtmlとphpの内容を表示するにはどうすればいいですか

+1

あなたは完全なHTMLを表示することができ、私はあなたが私が適切な位置にテーブルを閉じていなかった真 '歓迎-text'前 – AgeDeO

+0

ザッツをテーブルを閉じていないと思います。ありがとう – Mysterio4

+0

ヒント:HTML出力を検証すると、そのようなエラーを見つけるのに役立ちます。 https://validator.w3.org/ – CBroe

答えて

2

を固定し得るよう

<?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のか、準備されたステートメントを使用します。

<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

関連する問題