开发者

php/mysql search and replace a parts of a sentence

Replacing parts of a sentence in 开发者_StackOverflow社区mysql table using php.I need help in getting this done rightly. eg. replacing http://www.gettingthingsdone.com/products/electronics with http://www.gettingthingsdone.com/electronics

$sql = "UPDATE ".$table_name."
                        SET ".$val." = '".$SearchAndReplace_replace_with."'
                        WHERE ".$val." LIKE '"."%".$SearchAndReplace_search_term."%"."'";


You should consider to use REPLACE of mysql that is designed what are you looking for. before executing the command take the backup of table.

   UPDATE [your_table_name] SET [your_table_field] = REPLACE([your_table_field],
 '[string_to_find]' , '[string_to_be_replaced]')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜