Jump to content

How do I keep simple text formatting when echo'd from database?


DiscoTrio

Recommended Posts

Ok, I have a database with tons of user-submitted data, each somewhere over 200 characters.  When I do a normal way of echoing a row from it all formatting is gone.  (I dont mean like bold and stuff, there is no coding in text) but where the user hits enter is gone.  For example:

 

User enters this:

Hi, Im Bob

This is my text entry.

 

Database knows its this:

Hi, Im Bob

This is my text entry.

 

Comes out on php page as this:

Hi, Im BobThis is my text entry.

 

Here is the code that echo's the data, I just wanna know how to keep that formatting there...

 

$result = mysql_query("SELECT * FROM snews WHERE id = '0' LIMIT 0,1");

while($row = mysql_fetch_array($result))
  {$cnumber = $row['id2'];
    $pointsgetter = $row['username'];
    $article = $row['id2'];
  echo $row['username'] . " wrote:<br>" . $row['title'] . "<br><br>" . $row['content'] . "<br><br>About: " . $row['game'];
  echo "<br><a href='mod1.php?action=approve&cnumber=$cnumber'>[Approve]</a>";
  echo " <a href='mod1.php?action=delnews&cnumber=$article'>[Delete]</a>";
}

Link to comment
Share on other sites

because html sucks, they dont show newline character, even u have in code\

they only show <br /> as new line

 

Because html sucks? How does that suck, it was designed that way for a very good reason. If it was not then you would get a TON of new lines just from the code being on separate lines itself and if you were to only code new lines when text was involved, well that would be a mess of code and very hard to read.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.