Reading a text with wordwrap from MySQL database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Kaischum
Forum Newbie
Posts: 2
Joined: Tue Jul 02, 2002 9:41 am

Reading a text with wordwrap from MySQL database

Post by Kaischum »

Hi,
I have saved a text including wordwraps in a MySQL database. PHPMyAdmin shows the text correctly saved in my table. Now I want to read out the text with PHP and display it INCLUDING the wordwraps. This doesn't function, the text is displayed in one line.
This is the code:

$sqlab = "select * from ABIGB Order by 'ID' desc";
$res = mysql_db_query($database, $sqlab);
$kommentar = mysql_result($res, $i, "Kommentar");

then later: echo $kommentar;

Does anyone know what I did wrong?

Thanks Kai
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

look at the nl2br() function, which turns all of the line feeds into <br>
Kaischum
Forum Newbie
Posts: 2
Joined: Tue Jul 02, 2002 9:41 am

Post by Kaischum »

Thanks, this helped!
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Actually, just to clarify, it turns newlines into <br />, which is XHTML compliant.

Just to nitpick.
Post Reply