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!

 

 

 

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

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.