Welcome to WebmasterWorld Guest from 54.147.63.124

Forum Moderators: open

Message Too Old, No Replies

Remove or update all anchor tags in 3 columns

Is there a way to do this in MySQL

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 22, 2003
posts:1022
votes: 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

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

Senior Member

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Dec 9, 2003
posts:3416
votes: 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.
8:18 am on Mar 24, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 22, 2003
posts:1022
votes: 0


Thanks whoisgregg

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

-Gs
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members