Solved

run column2 through a function and output would be in column3

Posted on 2014-02-17
3
205 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 108

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now