Jump to content

Adding a variable to the beginning of another in a db (concatenating?)


rotour

Recommended Posts

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!

 

 

 

Link to comment
Share on other sites

$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!

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.