title: use a while mysql_fetch_array and UPDATE during the loop - PART TWO
body: <p>I apologize for not knowing how else to do this. I went to add to my other <a href="https://stackoverflow.com/questions/5132155/use-a-while-mysql-fetch-array-and-update-during-the-loop">question</a>, and I could not figure out how to append this to it.</p>
  
  <p>I am trying to apply your answer to the previous <a href="https://stackoverflow.com/questions/5132155/use-a-while-mysql-fetch-array-and-update-during-the-loop">question</a> in another place. </p>
  
  <p>In this instance I have a bit more going on but thought I could do the same thing as above -with the adjustment of changing <code>id</code> for user_name, since the ids would not match table to table, but the user_name does. I know I am biting off a lot for my first project but I really like this coding stuff. Hope I am not pulling on too many shirt tails. Thanks for your help.</p>
  
  <p>Heres the code. Its placing the same user_name in every row(like the previous question was)</p>
  
  <pre><code>&lt;?php
  
  $Var1 =$_POST['Var1'];
  
  require("connection.php");
  
  mysql_query("UPDATE table1 SET actor = '$Var1'");
  
  $result = mysql_query("SELECT * FROM table2 WHERE subject ='$Var1'");
  
  while($row = mysql_fetch_array($result))
    { $un = $row['user_name'];
       $a =$row['subject'];
       $a_val = $row['subject_val'];
  
      $sql=mysql_query("UPDATE table3 SET user_name='$un', subject='$', subject_val= $a_val WHERE user_name=".$row['user_name']);     
  
    }
   mysql_close($connection);
  ?&gt; 
  </code></pre>