$msg = "original message"; # assume this is from the prev message $reply = $newmsg . "\nOriginal Message\n------------\n" . $msg; # and then just insert the reply into messages table with SQL insert INSERT INTO messages (message_id, recipient_id, sender_id, message, date, status) VALUES (?, ?, ?, ?, ?, 'NR')