PHP-MySQL-PHP: Line skipping/spacing
Moderator: General Moderators
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
PHP-MySQL-PHP: Line skipping/spacing
Hello.
If I use a form to input something (through PHP) into a MySQL database, and call on it to display, it comes out with screwed up line spacing. And line spacing is important every once in a while. I found I can eliminate this problem by putting the HTML tag <br> right into the form, but this is no good if a user is doing the input. How can this be done automatically when a user goes to the next line?
Cheers!
If I use a form to input something (through PHP) into a MySQL database, and call on it to display, it comes out with screwed up line spacing. And line spacing is important every once in a while. I found I can eliminate this problem by putting the HTML tag <br> right into the form, but this is no good if a user is doing the input. How can this be done automatically when a user goes to the next line?
Cheers!
which form-element do you use? <input> or <textarea>?
Maybe you want http://www.php.net/manual/en/function.nl2br.php
Maybe you want http://www.php.net/manual/en/function.nl2br.php
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
I don't really understand, can you give me an example?
I'm using textarea, and I want the <br> tag to appear whe a user goes to the next line.
Bieng more clear, the way the text is entered and retrieved now, where the line ends depends on the size of the ie/netscape winodw. I want it to end whereever the user wanted it it to end.
Thanks.
I'm using textarea, and I want the <br> tag to appear whe a user goes to the next line.
Bieng more clear, the way the text is entered and retrieved now, where the line ends depends on the size of the ie/netscape winodw. I want it to end whereever the user wanted it it to end.
Thanks.
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You don't really want to have <br> tags appearing in the text area because although you can't see it newlines characters are being added each time the person presses enter. What nl2br() does is, when you want to redisplay this information, it adds an HTML linebreak (<br />) next to the newline character so not only does the source have the newlines apparent, the output on the screen does too.
Mac
Mac
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada