Solved

run column2 through a function and output would be in column3

Posted on 2014-02-17
3
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 110

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This article discusses how to implement server side field validation and display customized error messages to the client.
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 look for a specific file type in a local or remote server directory using PHP.

726 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