PHP help again

- English -

Resident Freddy
Joined
Apr 7, 2004
Messages
5,263
This is part of my form for a textarea field. I am reading from the database (['content'] being the database row). I want it so when i format in the textarea field, it keeps the same format when it submits to the HTML page.



Code:
<p>Content: <br/></p>
		<textarea name="content" rows="10" cols="32"><?php echo $sel_subject['content'];?></textarea></p>

For example;

Hello
1
2
3

should print out the same in HTML.
However its printing out as Hello 1 2 3.

Ive been trying to look up how, and there seem to be a number of ways, although none I have found help me to implement them. They just give the functions.

string nl2br()
and str_replace

Can anyone help me, ive tried every combination of trying to get it to work!


Code:
<p>Content: <br/></p>
		<textarea br2nl($sel_subject['content']) name="content" rows="10" cols="32"><?php echo $sel_subject['content'];?></textarea></p>

:S
 

Sparx

Cheeky Fucknugget
Joined
Sep 30, 2005
Messages
8,059
I think my sperm just got headaches

I hate coding lol
 

ST^

Can't get enough of FH
Joined
Dec 22, 2003
Messages
2,351
nl2br is exactly what you want. You need to put it where you're echo'ing the text.

echo nl2br($sel_subject['content']);
 

- English -

Resident Freddy
Joined
Apr 7, 2004
Messages
5,263
nl2br is exactly what you want. You need to put it where you're echo'ing the text.

echo nl2br($sel_subject['content']);

dam was so close! :(

It kinda works .. well

Upon typing text and pressing submit, it inserts the <br/> tags

Tho you need to resubmit it to take affect on the html page.

Any way around this?
 

ST^

Can't get enough of FH
Joined
Dec 22, 2003
Messages
2,351
Umm...

You don't do nl2br on the stuff INSIDE the textarea, only on whatever you're echo'ing outside of it.
 

liloe

It's my birthday today!
Joined
Jan 25, 2004
Messages
4,166
Shouldn't the nl2br function be inside the <?php ?> tags?
 

Tuthmes

FH is my second home
Joined
Jun 18, 2004
Messages
5,495
Try using text align and/or make another <div> inside the content. Will have a serious look if you're still stuck!
 

liloe

It's my birthday today!
Joined
Jan 25, 2004
Messages
4,166
XHTML just isn't worth it now

One day I wanted to try it and since then I've adopted the standard =) I'm a bit of a freak and XHTML touched my sense for pedantic coding ;)
 

- English -

Resident Freddy
Joined
Apr 7, 2004
Messages
5,263
I fixed it :)

ST was right

Thanks for all the help tho guys, i guess i will have more sometime soon! :)
 

Users who are viewing this thread

Top Bottom