run column2 through a function and output would be in column3

using mysqli, or pdo

I would like a php function that prepends 'begin' and postpends 'end' to an existing varchar field

table.column1 int primary key autoincrement
table.column2 varchar
table.column3 varchar


example output
5454  begin5454end
656    begin656end
4        begin4end
A        beginAend
LVL 1
rgb192Asked:
Who is Participating?
 
Cornelia YoderConnect With a Mentor ArtistCommented:
UPDATE table SET column3 = CONCAT("begin",column2,"end")
0
 
rgb192Author Commented:
yes that works using only mysql.
Thank you.
0
 
Ray PaseurCommented:
I guess you could write a function, but it might be easier to write a single line PHP statement like this:

$old = '5454';
$new = 'begin' . $old . 'end';
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.