title: How to update only non-empty values in a table?
body: <p>How do I update only the non-empty values? </p>
  
  <p>I have an SQL code for updating a result set.                                           </p>
  
  <p>But after I submit my form, the values I did not input would also be updated and record as empty values in the database. </p>
  
  <p>Here is my code</p>
  
  <pre><code>$insert = "UPDATE result SET test_1= '$test_1', test_2= '$test_2', 
                   test_3= '$test_3', test_4= '$test_4', 
                   test_5 = '$test_5' 
                  WHERE roll_no = '$roll_no'";
  </code></pre>
  
  <p>And the form</p>
  
  <pre><code> &lt;form action="#" method="post"&gt;
   &lt;input type="text" name="test_1" required="" class="" &gt;
   &lt;input type="text" name="test_2" required="" class="" &gt;
   &lt;input type="text" name="test_3" required="" class="" &gt;
   &lt;input type="text" name="test_4" required="" class="" &gt;
   &lt;input type="text" name="test_5" required="" class="" &gt;
   &lt;button type="submit" class="" name="sub"&gt;SUBMIT&lt;/button&gt;
  </code></pre>
  
  <p>If i fill in only <em>test_1</em> and <em>test_2</em>, i want other columns to be unaffected, since there are no inputs.</p>