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]')
精彩评论