php mysql替换字符串方法

  1. <?php
  2. function replace(){
  3. $sql = db_query("SELECT field_languages_value,nid FROM {content_type_company_profile} WHERE
  4. field_languages_value like '%Mandarin Chinese%'");
  5. while($result = db_fetch_object($sql)){
  6. $a = explode("Mandarin Chinese",$result->field_languages_used_value);
  7. $b = $a[].'Chinese'.$a[1];
  8. db_query("UPDATE content_type_company_profile SET field_languages_used_value = '%s' WHERE nid = %
  9. //phpfensi.com
  10. d",$b,$result->nid);
  11. }
  12. }
  13. ?>