Help with UPDATE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dennis73
Forum Newbie
Posts: 10
Joined: Wed Oct 17, 2007 2:51 am

Help with UPDATE

Post 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
sunilbhatia79
Forum Newbie
Posts: 24
Joined: Sun Nov 11, 2007 9:37 pm
Location: Mumbai, India

Post 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
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
dennis73
Forum Newbie
Posts: 10
Joined: Wed Oct 17, 2007 2:51 am

Post 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!
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post 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.
dennis73
Forum Newbie
Posts: 10
Joined: Wed Oct 17, 2007 2:51 am

Post by dennis73 »

Thanks, I have managed to code this to do precisely that. Thanks for the help, much appreciated
Post Reply