Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-31-2009, 07:27 PM   PM User | #1
TwilightRealm
New to the CF scene

 
Join Date: Aug 2008
Posts: 9
Thanks: 0
Thanked 3 Times in 3 Posts
TwilightRealm is an unknown quantity at this point
Question Use wildcard find and place segment of field in another field?

I'm wondering if it's possible to take part of a field information and insert it into another field?

I have a column called "idata" and some of the fields contain a segment of html data involving width="*px". It doesn't really say *, it's actually a number, but not every field has the same number.

I'd like to be able to use a sort of wild card, and say find the 'width="*px"' in the idata column and then put just the number in another field called in the imgwidth column, and replace the former number in idata with ''?

Is this possible? Otherwise I have to go through 550 rows, one at a time.
TwilightRealm is offline   Reply With Quote
Old 01-31-2009, 07:53 PM   PM User | #2
masterofollies
Senior Coder

 
Join Date: May 2005
Posts: 2,137
Thanks: 96
Thanked 72 Times in 72 Posts
masterofollies can only hope to improve
You could use LIKE % check for it.
masterofollies is offline   Reply With Quote
Old 01-31-2009, 08:14 PM   PM User | #3
TwilightRealm
New to the CF scene

 
Join Date: Aug 2008
Posts: 9
Thanks: 0
Thanked 3 Times in 3 Posts
TwilightRealm is an unknown quantity at this point
Can that work in a replace statement? To say find where like 'width="%"' and insert % into another field?
TwilightRealm is offline   Reply With Quote
Old 01-31-2009, 08:28 PM   PM User | #4
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
No, you can't use backreferences with replace. What you could do is loop through the rows, match/replace your string with a regular expression(preg_replace()), and update the row.
Inigoesdr is offline   Reply With Quote
Old 01-31-2009, 09:15 PM   PM User | #5
TwilightRealm
New to the CF scene

 
Join Date: Aug 2008
Posts: 9
Thanks: 0
Thanked 3 Times in 3 Posts
TwilightRealm is an unknown quantity at this point
Forgetting the wild card stuff, how would I go about saying 'find the phrase ("Created by Gareth") in this field, and insert ("Gareth") into another field'?

Nevermind, I remembered an UPDATE command can do this.

Last edited by TwilightRealm; 01-31-2009 at 09:56 PM..
TwilightRealm is offline   Reply With Quote
Reply

Bookmarks

Tags
field, move, part, segment, wild card

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:44 AM.


Advertisement
Log in to turn off these ads.