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.

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]

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

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.