Forums

PHP

This topic is locked

Retaining line breaks in forms

Posted 11 Aug 2004 11:09:56
1
has voted
11 Aug 2004 11:09:56 matt lockie posted:
I have a vacancy web site that displays jobs current available. I have a form to insert the information into an MySql Database including detail regarding the job. If I put line breaks in the text these pass fine into the database.

When I try to pull them back into a PHP page it displays as one long string of text that has been wrapped.

Can anybody help

Replies

Replied 30 Aug 2004 17:02:22
30 Aug 2004 17:02:22 Olaf Lederer replied:
from the php manual:

<pre id=code><font face=courier size=2 id=code>&lt;?php
$text = "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap($text, 20, "&lt;br /&gt;";

echo "$newtext\n";
?&gt;</font id=code></pre id=code>

Greetings from the Netherlands!
Olaf
_____________________
www.finalwebsites.com
Replied 06 Sep 2004 08:02:45
06 Sep 2004 08:02:45 Manuel Velazquez replied:
Probably it's too late but here it is anyway...
I came with the same problem a while ago and found this solution, can't remember where though

<pre id=code><font face=courier size=2 id=code>&lt; ?php echo nl2br($row_rsRECORDSET['field_name']); ?&gt;</font id=code></pre id=code>

It's a function that converts line breaks to html's br

Reply to this topic