Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6117187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:17:30+00:00 2026-05-23T15:17:30+00:00

I would like to be able to get html-formatted data from mysql, and turn

  • 0

I would like to be able to get html-formatted data from mysql, and turn the new lines into <br> or <p> tags.

I have been able to do this effectively with white-space: pre-wrap in the CSS, except for with IE7 and under.

My issue is that if I put a conditional nl2br() on the data if the browser is <=IE7, then it would create line breaks on the <li> tags, which already have line breaks, creating extra space between the bullets.

Is there a better way to do this?

My test page is:

http://logblog.net84.net/

And my code is (at this point in time):

...
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>
        </head>
        <style>
        p { white-space:pre-wrap;white-space:-moz-pre-wrap;word-wrap:break-word }
        </style>
        <body>
        <?php 
...
        $conn = mysql_connect($host, $user, $pw) or die('Error connecting to mysql');
        mysql_select_db($db);
        mysql_set_charset('utf8', $conn);
        $result = mysql_query("SELECT * FROM wp_posts WHERE post_status='publish' AND post_type='post'");

        while($row = mysql_fetch_array($result))
          {
          echo '<h2>'.$row['post_title'].'</h2>'; 
          echo '<p>'.$row['post_content'].'</p>';
          }
    ...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:17:31+00:00Added an answer on May 23, 2026 at 3:17 pm

    Are you trying to get around WordPress’s automatic Paragraph replacement? If so there is a built-in a function for you – http://codex.wordpress.org/Function_Reference/wpautop

    If not this then can you be a little more specific – it looks like your test page link did not come through on the post?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to be able to get the style from a CSS element
I have loaded HTML into pyqt and would like to create a list of
I would like to be able to get a list of all possible files
I would like to be able to get the name of a variable as
I would like to be able to obtain all the parameter values from the
I have a block of HTML that I would like to use as the
I have some html content stored in a database field. I would like trusted
Essentially, I have a dynamically generated local HTML form that I would like to
I would like to copy images from a iframe into a textarea. The pages
Would like to be able to set colors of headings and such, different font

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.