php mysql update form
<p>There's the code:</p>

<pre><code>$id = $_POST['id'];
$name = $_POST['name'];
$surname = $_POST['surname'];
$mail = $_POST['mail'];

$sql = "UPDATE emps SET";
$moresql = '';

if(isset($name) &amp;&amp; !empty($name)) {
    $moresql .= " name = '$name'";  
}

if(isset($surname) &amp;&amp; !empty($surname)) {
    if ($moresql) $moresql .= ',';
    $moresql .= " surname = '$surname'";    
}

if(isset($mail) &amp;&amp; !empty($mail)) {
    if ($moresql) $moresql .= ',';
    $moresql .= " mail = '$mail'";  
}

$sql .= $moresql;
$sql .= " WHERE Id = '$id'";
</code></pre>

<p>In this code i can update for example: name and leave existing values from surname and email or update surname and leave name and email existing values</p>

<p>But I want also at one time, for example: update name and surname and leave email existing value or update surname and email and leave name existing value or update all fields.
how?</p>
