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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP-MYSQL question

Status
Not open for further replies.

dadms

Technical User
Mar 8, 2003
67
0
0
US
I am trying to append to a field in a mysql database.

For example in field NOTES- I may have-
THIS IS A TEST

I then want to be able to add/append/update????-
TEST IS OVER

And in the DATABASE it would show-
THIS IS A TEST
TEST IS OVER

I currently use

$sql = "UPDATE logins SET notes='$notes' WHERE id='$id'";

but this replaces what I have in field already. Any suggestions?

Thanks
 
Not sure of the exact syntax. Along the lines of:

Connect to database...
Extract current value of the 'notes' field
$sql = "SELECT notes FROM logins WHERE id='$id'";
$query_result = // result from query

append query result to $notes
$notes = $query_result . $notes

$notes should now read "THIS IS A TEST TEST IS OVER"

Update database using:
$sql = "UPDATE logins SET notes='$notes' WHERE id='$id'";
 
Thanks for all the suggestions. I took the easy route and went with:

$sql = "UPDATE logins SET notes=CONCAT(notes, '$notes') WHERE id='$id'";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top