Solved

run column2 through a function and output would be in column3

Posted on 2014-02-17
3
207 Views
Last Modified: 2014-02-17
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
0
Comment
Question by:rgb192
3 Comments
 
LVL 27

Accepted Solution

by:
yodercm earned 500 total points
ID: 39865494
UPDATE table SET column3 = CONCAT("begin",column2,"end")
0
 

Author Closing Comment

by:rgb192
ID: 39865507
yes that works using only mysql.
Thank you.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39865535
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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question