title: Update a value on a column only if that value is different from empty
body: <p>I have this form, now, i need to update only the parts of the database with variables that are not empty.
  I mean, if i have this:</p>
  
  <pre><code>$postEmri       = filter_var($_POST["postEmri"], FILTER_SANITIZE_EMAIL);
  $postKlienti        = filter_var($_POST["postKlienti"], FILTER_SANITIZE_STRING);
  $postTelefoni   = filter_var($_POST["postTelefoni"], FILTER_SANITIZE_STRING);
  </code></pre>
  
  <p>And this:</p>
  
  <pre><code>$sql="UPDATE forma SET emri='$postEmri', klienti='$postKlienti', telefoni='$postTelefoni'";
  </code></pre>
  
  <p>If <code>$postEmri, $postKlienti</code> are <code>undefined</code> or <code>empty</code>, i don't want that record to be updated.
  How can i do it using some conditions?</p>
  
  <p>Thanks  </p>
  
  <p>So i need to do this?</p>
  
  <pre><code>$sql="UPDATE forma SET ";
  // add every non-empty field to the query
  if (!empty($postEmri)) $sql += " emri='$postEmri',";
  if (!empty($postKlienti)) $sql += " klienti='$postKlienti',";
  if (!empty($postTelefoni)) $sql += " telefoni='$postTelefoni,'";
  // replace the last `,` for `;`
  $sql = substr($sql, 0, -1) . ";";
  $result=mysql_query($sql) or die(mysql_error()) ;
  </code></pre>