title: dynamic sql UPDATE query
body: <p>How can I update a table in the data base where the SET clause from MySQL query depends on variables?  It can be one $var, two, or many more.</p>
  
  <p>Here is my ex. code:</p>
  
  <pre><code>$name = 'comp_name = "'.$nume.'",';
  $large = 'logolarge = "'.$linklogolarge.'",';  
  $small = 'logosmall = "'.$linklogosmall.'",';
  
  ...............................
  
   $sql = 'UPDATE company
      SET
              '.$name.'
              '.$large.'
              '.$small.'
      WHERE id_comp = 43 ';
  </code></pre>
  
  <p>The problem is that the normal syntax of the UPDATE query is that after SET .......between values needs a comma " , " </p>
  
  <p>ex.  </p>
  
  <pre><code>    UPDATE table 
       SET 
       col1 = x , 
       col2 = y , 
       col3 = z 
       WHERE id = 4
  </code></pre>
  
  <p>and at the end before WHERE doesn't needs one ..... ( ex. after " z ") </p>
  
  <p>So how can I make the sql query to accept different combination of those $var ...( only '.$name.' or '.$name.' and '.$large.' or only last two '.$large.' and '.$small.' .... etc)</p>
  
  <p>basically any combination between those 3 var ...and maybe combining more than 3 var.</p>