Page 1 of 1

Help with UPDATE

Posted: Tue Nov 13, 2007 3:09 am
by dennis73
Is it possible to build up a body of text in an update field from a bank of comments? For example, the user selects a sentence which goes into the textfield and when the next sentence is selected it goes in at the end of the previous one? The sentences are in a table called CmntBnk and i'd like them to go into a field called 'Cmnt' in table 'Feedback'.

In a past life as an Access developer I did this with a paste command, pasting text from one form directly into another. I also had a procedure to replace an <n> in the comment with the name of the person. Is there any way I can get near to this with PHP?

Thanks

Posted: Tue Nov 13, 2007 5:19 am
by sunilbhatia79
I am not really sure that I understand this...

Do you want to copy the data from table to another? If yes then you can directly do this using the MySQL itself like this:

I am assuming that you don't have the feedback table created.

Step 1: To copy all records to feedback table

create table feedback select * from cmntbnk;

Step 2: To change the name of the field to cmnt

alter table feedback change assumed_field_name_from_cmntbnk_table cmnt [DATA TYPE AS IN the cmntbnk table]

I hope I have understood your query correctly. In case of anything else, please feel free to ask for more :)

Sunil

Posted: Tue Nov 13, 2007 5:54 am
by Kieran Huggins
I have a feeling you'll need to use javascript and one of the various "selected text" methods.

check out http://www.codetoad.com/javascript_get_ ... d_text.asp and see if that speaks to you.

Posted: Tue Nov 13, 2007 6:13 am
by dennis73
Thanks guys. I'll check out the javascript. Rather than copying across a whole table i want users to be able to select the contents of records from that table and then have them pasted in to on field in the feedback table. It's because the feedback will be similar in nature for many respondants and it would save them having to provide text from scratch.

Thanks again!

Posted: Fri Nov 16, 2007 2:36 pm
by califdon
Are you saying that you just want to append some user text to the end of some existing text in a field? That would only require accessing the record, copying the current contents of the field into a variable, appending the user's input and then updating the record with the contents of the variable.

Posted: Mon Nov 19, 2007 6:07 am
by dennis73
Thanks, I have managed to code this to do precisely that. Thanks for the help, much appreciated