Updating url prefix with mysql query

Go To StackoverFlow.com

0

I have imported my database by script from live site to my local server.

I have menu system dynamically generated by database. they are in table like below:

id   name     linkpage
1    blog     http://www.example.com/blog/index.php
2    about    http://www.example.com/blog/about.php

I have to change live url in to my local url like http://www.example.com/blog/index.php to http://localhost/mysite/blog/index.php

How can I update link page column with mysql query ?

2012-04-05 16:42
by NoName


3

It's simple. You can do with replace function:

 UPDATE tablename SET linkpage=REPLACE(linkpage,'www.example.com','localhost/nysite')
2012-04-05 16:45
by NoName


0

with replace function;

mysql_query("UPDATE your_tablename SET linkpage=REPLACE(linkpage,'www.your_link.com','localhost/mysite')")
2012-04-05 17:42
by blasteralfred Ψ
refer http://dev.mysql.com/doc/refman/5.0/en/replace.htm - blasteralfred Ψ 2012-04-05 17:43
Ads