1

I am retrieving posts from my database but I want the <div class="welcome-text"><strong>This is my second output</strong> </div> to display below the retrieved table but its always displaying above. is there any way I can fix this:

<?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

Would use mysqli or prepared statement soon as I get this fixed

3
  • 1
    Can you show the full html, I guess you don't close the table before the welcome-text Commented Aug 24, 2016 at 8:18
  • Thats true I did not close the table at the appropriate position. Thanks Commented Aug 24, 2016 at 8:24
  • Hint: Validating your HTML output helps spot such errors. validator.w3.org Commented Aug 24, 2016 at 8:48

1 Answer 1

2

You din't close table tag before open div tag.

<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>
Sign up to request clarification or add additional context in comments.

1 Comment

Its working fine now, I should have closed table before the div

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.