title: SQL Update/Insert with loop for $_GET
body: <p>I'm using ajax scripts for most of my site's functionality. In order to update or insert a row in particular table i send the request with $_GET, then retrieve each value with</p>
  
  <pre><code>foreach ($_GET as $item =&gt; $value){
          $$item =addslashes($value);
      }
  </code></pre>
  
  <p>and then i have this SQL Statement for the query</p>
  
  <pre><code>if($_GET['action']=='update'){
       $sql =$conn-&gt;query("UPDATE `newDrivers` SET `idCompany`='$idCompany', ...
       WHERE `id`='$id'");
  }
  else{
       $sql =$conn-&gt;query("
      INSERT INTO `newDrivers`(`idCompany`, ...) 
      VALUES ('$idCompany', ...)");
  } 
  </code></pre>
  
  <p>I see inefficiency, naming each column and creating new file for each table i have. Is there any way i can update/insert without naming each column individually so the script would be more of a universal one?</p>