Page 1 of 1

Reading a text with wordwrap from MySQL database

Posted: Tue Jul 02, 2002 9:41 am
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

Posted: Tue Jul 02, 2002 10:46 am
by mikeq
look at the nl2br() function, which turns all of the line feeds into <br>

Posted: Tue Jul 02, 2002 12:07 pm
by Kaischum
Thanks, this helped!

Posted: Tue Jul 02, 2002 1:02 pm
by jason
Actually, just to clarify, it turns newlines into <br />, which is XHTML compliant.

Just to nitpick.