rotour Posted November 16, 2010 Share Posted November 16, 2010 Hi, I have two variables: $latest_note and $notes. Whenever I update $latest_note, I also want this (and today's date) to be added to $notes, such that $notes becomes a sort of archive of all of the latest notes, listed by date. I tried creating a third variable called $full_notes and saying $full_notes = $latest_note.$notes; ... then when I run my mysql update, I set notes='$full_notes' but it's not working properly. Is there a way to simply add one variable to the beginning of another in the db directly, concatenating the two? Thanks! Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted November 16, 2010 Share Posted November 16, 2010 what do you mean by "it's not working properly"? can you post your code? Quote Link to comment Share on other sites More sharing options...
rotour Posted November 16, 2010 Author Share Posted November 16, 2010 $full_notes = $latest_note.$notes; $result = mysql_query("UPDATE whosay SET latest_note='$latest_note', notes='$full_notes' WHERE id='$id'"); if ($result){ // If successful, return to detail page with update notice header ("Location: ".$httppath."editclient.php?wid=".$wid."&update=ok"); By "not working," I mean that the $latest_note is not being added to the $notes. But my main question is, is this even the right way of doing this, or is there a cleaner command or something I can use to merely insert a variable into another variable in a database, but adding that variable to the beginning rather than replacing the entire value. Thanks for your help! Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted November 16, 2010 Share Posted November 16, 2010 i think it should work as posted. where is $lastest_note set? I would echo it before you set $full_notes to make sure it's what you expect. Quote Link to comment Share on other sites More sharing options...
rotour Posted November 16, 2010 Author Share Posted November 16, 2010 Ah, I went back after trying what you suggested and found an error earlier in my code. Thanks for your help! Quote Link to comment 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.