text area info...

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

text area info...

Postby bezmond » Sun Apr 13, 2003 7:50 am

Hi all,
how can I insert details from a text area into a database with line breaks etc inserted without anyone having to type "<br>"?

Any help would be greatly appreciated.

Best Regards,
Andrew

php-vikas
New php-forum User
New php-forum User
Posts: 164
Joined: Mon Apr 14, 2003 12:25 am
Location: India
Contact:

Postby php-vikas » Mon Apr 14, 2003 12:54 am

hi

You can do this thing by just using a single function before the final insertion of text area value into the database.

i.e.

Text_area_variable_name=nl2br(Text_area_variable_name)

I hope this would work fine.

If it is not going to work, then please dont hasitate to ask.

Vikas Garg

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Postby bezmond » Mon Apr 14, 2003 1:00 am

*YES*

Cheers!!

Andrew

php-vikas
New php-forum User
New php-forum User
Posts: 164
Joined: Mon Apr 14, 2003 12:25 am
Location: India
Contact:

Postby php-vikas » Mon Apr 14, 2003 1:06 am

is my reply work for you.

by the way in which profession you are?

I am web-developer

Vikas

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Postby bezmond » Mon Apr 14, 2003 1:22 am

Yep it works.

I'm by profession a student, but I'm working on a remake of a former ASP website... what I just asked was for the forum :)

Andrew

mynmonic
New php-forum User
New php-forum User
Posts: 18
Joined: Tue Nov 26, 2002 3:35 am
Location: Hong Kong
Contact:

Postby mynmonic » Fri Jun 13, 2003 12:40 am

I tried the nl2br() but donno why it's not working as what I espect.

is that this function turn

"This is line one
This is line two"

into

"This is line one<br /> This is line two" ?

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Postby bezmond » Fri Jun 13, 2003 4:31 am

a test post in the forum I was creating:

"This is a test post, please ONLY test on this topic.<br />
<br />
Andrew"

so yes, that is how it should work.

Andrew

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Postby WiZARD » Fri Jun 13, 2003 11:13 pm

in HTML need to do and no matter how you do like that:

Code: Select all

This is string number one<BR>
This is string number two
or

Code: Select all

This is string number one<BR>This is string number two

HTML do not understand double space, only one.
in PHP need to do:

Code: Select all

echo("This is string number one \n This is string number two");

that "\n" and mean bl
but under Windows need type \n\t unde *nix just \n

mynmonic
New php-forum User
New php-forum User
Posts: 18
Joined: Tue Nov 26, 2002 3:35 am
Location: Hong Kong
Contact:

Postby mynmonic » Mon Jun 16, 2003 7:35 am

Thanks
I will use Google before asking dumb questions I will use Google before asking dumb questions I will use Google before asking dumb questions I will use Google before asking dumb questions I will use Google before asking dumb questions I will use Google before asking dumb questions I will use Google before asking dumb questions I will use Google before asking dumb questions
:lol:

User avatar
mike
New php-forum User
New php-forum User
Posts: 73
Joined: Sun May 04, 2003 4:26 am
Location: Athens
Contact:

Postby mike » Sun Jun 22, 2003 3:57 pm

$text = str_replace("\n","<br>",$text);

ukmdb
New php-forum User
New php-forum User
Posts: 7
Joined: Sat Jun 21, 2003 12:56 pm

Postby ukmdb » Wed Jun 25, 2003 3:49 am

php-vikas
I have search high and low.
Your answer to this solved my problem straght away, Thank you


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest