dark_destroyer Posted April 22, 2007 Share Posted April 22, 2007 Hi All, I am tryin to update a field in a table but i dont want to overwrite whats already there i want to add info to the end of the info already there, for example Field 1 Field 2 Test Test 2 would become Field 1 Field 2 Test Test2 and Test 3 ive just been using the usual insert code: mysql_connect("localhost", "root","2233home") or die(mysql_error()); mysql_select_db("task_logging") or die(mysql_error()); $query="UPDATE in_progress SET steps_taken = '$_Actions' where ID = '$_ID'"; $result=mysql_query($query) or die ("Error in the query" .mysql_error()); mysql_close(); But this just simply overwrites the inital data in the field. Quote Link to comment https://forums.phpfreaks.com/topic/48117-adding-to-a-field-instead-of-overwriting-updated/ Share on other sites More sharing options...
MadTechie Posted April 22, 2007 Share Posted April 22, 2007 try <?php mysql_connect("localhost", "root","2233home") or die(mysql_error()); mysql_select_db("task_logging") or die(mysql_error()); $query="UPDATE in_progress SET steps_taken = CONCAT(steps_taken,'$_Actions') where ID = '$_ID'"; $result=mysql_query($query) or die ("Error in the query" .mysql_error()); mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/48117-adding-to-a-field-instead-of-overwriting-updated/#findComment-235161 Share on other sites More sharing options...
dark_destroyer Posted April 22, 2007 Author Share Posted April 22, 2007 Thanks Mad Techie, it works a treat! Quote Link to comment https://forums.phpfreaks.com/topic/48117-adding-to-a-field-instead-of-overwriting-updated/#findComment-235173 Share on other sites More sharing options...
dark_destroyer Posted April 22, 2007 Author Share Posted April 22, 2007 Sorry,i thought it was solved, the CONCAT will only work when there is already data in the field, if the field is blank then it wont work?? any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/48117-adding-to-a-field-instead-of-overwriting-updated/#findComment-235179 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.