Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert new lines in column of a table 1

Status
Not open for further replies.
Feb 17, 2005
23
US
Hi
i have a table where i have 2 columns

table

AutoID(int) ServiceNotes(Text)
1 Visit-1:Test1
Visit-2 Test2

2 Visit-10:test3

whenever insert a row into this table.It should put the first notes in first line and whenever i add more notes it should go to next line in the ServiceNotes column

how to do it

pls let me know

thanks
 
Just so we are clear, when you say "insert row", you are talking about inserting a new id with new notes?

And when you say "add more notes" you are talking about updating a current row? IE: add to the existing data already there?
 
I assume you hit the enter key between the notes in the column for the notes.
For display purposes you should just use nl2br($row['ServiceNotes'])and the newline chars will be converted to <br /> tags.
 
How to add the enter key in the column using update statement when i add more notes to it?

can you pls give me the syntax for it.
thanks
 
All you need is a newline character. In PHP you can create that with doublequotes and "\n".
Code:
$text = "Hi there.";
$text .= "\nAnother line";
$text .= "\nYet another line";

echo nl2br($text);

Ok?
 
$servicenotes=$servicenotes .$post_["yournewnotevarhere"] . '<br>'

 
hi
i tried ur suggestions both of them print <br /> in the text area or <br> tag when i display in the text area on the form.

how to do it

pls
thanks


 
a) When you have to display the data in a table - that is in the HTML context - then use nl2br before displaying it.

b) When you use the data to populate a <textarea> then do not use the nl2br as the newlines will be correctly rendered without the need to convert them to <br /> tags.

So, all depends on the context.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top