title: php search/replace empty records in mysql
body: <p>Trying to do a search and replace using php/mysql. I do this in specified table headers/columns. it works fine when my search term has a value. However i want to search for an empty field in a specified column and replace with a value. it fails to do a search and replace when my search term is an empty string. Any help?</p>
  
  <pre><code>$SearchAndReplace_header = isset($_POST['SearchAndReplace_header']) ? $_POST['SearchAndReplace_header'] : "";
  
  $SearchAndReplace_search_term = isset($_POST['SearchAndReplace_search_term']) ? $_POST['SearchAndReplace_search_term'] : "";
  
  $SearchAndReplace_replace_with = isset($_POST['SearchAndReplace_replace_with']) ? $_POST['SearchAndReplace_replace_with'] : "";
  
  //foreach($fields as $key =&gt; $val) {
   //   if($SearchAndReplace_header == "all" || ($SearchAndReplace_header == $val)) {
          // replace column value with parameter value
          $sql = "UPDATE ".$table_name." SET ".$val." = REPLACE(".$val.",'".$SearchAndReplace_search_term."','".$SearchAndReplace_replace_with."')";                                              
          $db-&gt;query($sql);
     // }
    // }
  </code></pre>