开发者

php/mysql search and replace a parts of a sentence

开发者 https://www.devze.com 2023-02-20 17:08 出处:网络
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:/

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

精彩评论

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