get text exactly as is form text box

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jefffan24
Forum Commoner
Posts: 72
Joined: Mon Nov 02, 2009 8:18 am

get text exactly as is form text box

Post by jefffan24 »

I know how to get the text from text boxes but it is not grabbing line breaks so like if somebody type the following in a text box:

a

b

c

d

Right now it comes out as abcd. How can I get the spacing to stay? Also this has to be stored in a mysql database if that makes any difference.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: get text exactly as is form text box

Post by AbraCadaver »

Use nl2br() that converts the newlines to HTML <br> tags. Depending upon how you want to do this, you can do it before inserting it into the DB or do it when you want to display.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
jefffan24
Forum Commoner
Posts: 72
Joined: Mon Nov 02, 2009 8:18 am

Re: get text exactly as is form text box

Post by jefffan24 »

worked perfectly thanks.
Post Reply