homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

Remove or update all anchor tags in 3 columns
Is there a way to do this in MySQL
Alternative Future

 8:58 am on Mar 23, 2010 (gmt 0)

Greetings to the forum

I have a table with three columns, description1, description2 & description3. In these columns I have various anchor tags linking to other articles on my site i.e.
This description talks about this item and has a <a href="/dir/item2.html">link</a> to other items on my site. It may go on to talk about another <a href="/dir/dir2/another-item-id-213.html">another item</a>. The amount of <a href="/another-item-id-214.html">links</a> can be more than one or none

I am in the process of changing the whole sites URL structure (a big gamble I know), and now wish to remove all the anchor tags from all the descriptions, so that there is no internal links in the columns. Is there a sql command that I can run that would complete this?

With thanks in advance




 5:01 pm on Mar 23, 2010 (gmt 0)

There's no way in MySQL to do this directly that I know of. So, probably the easiest way to do this would be to loop through the rows using PHP (or some other server side language), strip out the tags, and update the rows with the new value.

Using the strip_tags() [php.net] function in PHP could do the trick (you can whitelist any html tags you want to keep) or you can use preg_replace() [php.net] if strip_tags would remove more than you want it to.

Alternative Future

 8:18 am on Mar 24, 2010 (gmt 0)

Thanks whoisgregg

I shall have a look into how to do this with Java6


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved