title: updating data in mysql database using arrays
body: <p>I would like to update information that is already in the database, but using an array.  I get 'successfully update' message white the data in the database is not updated.</p>
  
  <p>the following is the function I use to do the insertion:</p>
  
  <pre><code>function update_knowledge_modules($update_data,$value)
  {   
      $update = array();
      array_walk($update_data,'array_clean');
  
      foreach($update_data as $field=&gt;$data)
      {
          $update[] = '.$field. = \''.$data.'\'';
      }
  
  
  
      $query = "UPDATE knowledge_modules SET".implode(', ',$update)."WHERE curr_code =$value";
  
      mysql_query($query)
      or die(mysql_error);
  
  }
  
  &lt;?php
  
                      if(isset($_GET['success']) == true &amp;&amp; empty($_GET['success'])==true)
                          {
                              echo 'Changed successfully';    
                          }
                      else
                          {
                              if(empty($_POST)== false &amp;&amp; empty($errors)== true ) 
                                  {
                                      $update_module = array(
                                      'KM_Number'=&gt;$_POST['KM_Number'],
                                      'KM_Title'=&gt;$_POST['KM_Title'],
                                      'NQF_Level'=&gt;$_POST['NQF_Level'],
                                      'Credits'=&gt;$_POST['Credits']
  
  
                                      );
  
                                      update_knowledge_modules($update_module,$_SESSION['Curr_Code']); 
                                      header('Location:edit_km_details.php?success');
                                      exit();
                                  }
                          else if(empty($errors)== false)
                              {
                                  echo output($errors);
                              }
  
                ?&gt;
  
              &lt;form action="edit_km_details.php" method="POST"&gt;
  </code></pre>