PDA

View Full Version : PHP - Text Field Question




MrSugar
Dec 9, 2004, 04:09 PM
Hey guys,

So since I last got some help here with PHP and MySQL I have been going coder crazy. I am really enjoying the way a database can make a site work soooo much better.

I have created this nifty review script for CD's. You can add the band, artist, cd format, review scores, etc. You can even upload the CD cover and I have a script that will thumbnail it and add it into the review automatically. So all is good, except I am stumped by one thing.

I would like my text fields for certain things to automatically incorperate BRs every time I hit enter. For instance, this is most noticeable on the Track Listing. I have tracklisting as one text field, I want to have one track per line. However, as it is right now I have to add <br> at the end of each track to get it to the next line.

Is there anyway to make it so when I hit enter it will automatically BR that line?



Rower_CPU
Dec 10, 2004, 01:17 AM
For processing the text field after pulling it from the database, you can use the nl2br (http://us2.php.net/manual/en/function.nl2br.php) function to convert the new lines in the string to <br> tags.

MrSugar
Dec 10, 2004, 04:26 PM
For processing the text field after pulling it from the database, you can use the nl2br (http://us2.php.net/manual/en/function.nl2br.php) function to convert the new lines in the string to <br> tags.

Thank you so much, it worked great.