Jump to content

Echo-ing MySQL content and Keep Formatting?


Mundo

Recommended Posts

What do you mean? If you output things, it'll be output verbatim. If you output things to a browser with an text/html MIME type it will ignore consecutive whitespace, however (check the source). You can use nl2br to convert line breaks (ASCII code 10) to (X)HTML line breaks. You can also use CSS rules to preserve whitespace.

Link to comment
Share on other sites

Well basically the data in the database has linebreaks but when i output it the linebreaks disappear... I want them back without having to insert HTML into the database.

 

As you can see in my screenshot... I want my linebreaks to back to make it more readable.

 

[attachment deleted by admin]

Link to comment
Share on other sites

		$query = mysql_query("SELECT * FROM recipes WHERE id = '$_GET[recipeid]'");
	$row = mysql_fetch_assoc($query);

	$method = $row['method'];
	$method = str_replace('<br />', "\n", $method);

 

I've currently got this, but this won't add my line breaks back in either.

 

What do you mean, see the format i've already done?

Link to comment
Share on other sites

Dan was trying to teach you, new line to brake,

 

Look at the examples in the below link your understand.

 

http://uk2.php.net/nl2br

 

Siide note.

 

when you enter information in the database, as a brake <br> it's referenced as a special character, to tell the database it a brake <br>,

 

you Paul them brakes out using nl2br() function.

 

 

database example with $row

 

$text=nltbr($row['text']);

 

echo $text walla.

Link to comment
Share on other sites

dan i tried again lol.

 

 

Dan was trying to teach you, new line to brake,

 

Look at the examples in the below link your understand.

 

http://uk2.php.net/nl2br

 

Side note.

 

when you enter information in the database, as a brake <br> it's referenced as a special character, to tell the database it a brake <br>,

 

you Paul them brakes out using nl2br() function.

 

 

database example with $row

 

$text=nltbr($row['text']);

 

echo $text walla.

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.