0

Hello All:

I'm working on a project that requires me to perform a process of taking user input from a form's textarea and appending it to another text field in the database.

This field already has information in it. I want to be able to append the new value separated by a line and time&data stamp --at the point of the new addition.

Is this achievable? I realy hope someone is familar with this and can provide help.

My database is MYSQL and abviously, PHP is the scripting language.

Thanks for the time!
Mossa

3
Contributors
6
Replies
8
Views
6 Years
Discussion Span
Last Post by mbarandao
0

There is 2 ways you can do this, depending on what you have available to you at the time of saving.

If you have the data that was already in the field available in a variable, then best to just use PHP to append the addition to the string.

or you can use the SQL function CONCAT() to do it for you

UPDATE myTable SET message=CONCAT(message, '$newMessage') WHERE id=$myMessageID

as for adding a timestamp or newline you can use sprintf()

$newMessage = sprintf("\n%s - %s", date("d/m/Y"), $form_newMessage);

might check syntax, writing from memory and before bed ;)

anyway, hope this helps you.

0

Thank you =OTS=G-Man, for the reply. I actually figured it out last night. My solution is quite similar to one of the ones you suggested. I used the following.

$inputbox= "\n-----"."\n".' on '.date('Y-m-d H:i:s')."\n$inputbox\n--------------";

It works fine! If may however ask: If I want this new information to be appended at the top of any exiting information, how do I achieve this?

Currently, the appending is done on the bottom of any existing information.

Your thoughts!
Mossa

0

Thanks for the post ardav; however, I am trying to position the new data being appended at the top of the existing data...currently, it appends at the bottom.

0

Thanks ardav! Got it.. thanks for the post and assistance. All is well now!

The very best
Mossa

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.