Dynamic PHP/MySql Text Update

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
richo
Forum Commoner
Posts: 58
Joined: Sun Aug 06, 2006 11:56 am

Dynamic PHP/MySql Text Update

Post by richo »

Hi,

I want the user to be able to use a textarea (also displaying the current data from a row inside it) and edit the text, click submit and it update the table column.

I also want to know if this will detect breaks/ new paragraphs or if there will be something i need to add to get it to do this.

Any help, much appreciated.

thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Handling the textarea submission is standard form handling. PHP nor MySQL will detect the breaks or paragraphs; they just don't care. You will need things like nl2br() to make the text more like what the user will likely expect to see.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

As feyd said, characters like newlines and tabs will be saved in the database field and retrieved when you fetch that row. The upside is that the text is formatted as person entered it when you reload. A downside is that if you ever want to export to tab/other delimited then you will need to remember to strip out those characters.
(#10850)
richo
Forum Commoner
Posts: 58
Joined: Sun Aug 06, 2006 11:56 am

Post by richo »

Cheers guys. I asked some of my friends and they said i could do it with a REPLACE as part of the mySQL statement that adds it to the table.

thanks for your help,

Richo
Post Reply