title: UPDATE inside a WHILE statement
body: <p>So, I have a page with a bunch of workorders on it. Each workorder is a row in a single table, and gets put on the page with a while() statement. 
  I'm trying to update each row with a simple form that I put inside the while(), and an UPDATE/WHERE statement to actually add the information to the table.</p>
  
  <p>Instead of adding it to the specific row, it adds it to Every row. The only thing I can think of is that my WHERE condition is wrong, but I can't seem to figure it out. Maybe it just needs fresh eyes, or maybe I'm heading in Completely the wrong direction.</p>
  
  <p>Also, any specific instructions on security, a better way to do it, etc. would be very helpful. I'm learning PHP on the fly and could use a helping hand. :)</p>
  
  <pre><code>&lt;?php
  
          $query = "SELECT * FROM client_information"; 
  
          $result = mysql_query($query) or die(mysql_error());
  
  
          while($row = mysql_fetch_array($result)){ 
  
          $which_ad = $row['ID'];?&gt;
  
              &lt;b&gt;Name:&lt;/b&gt; &lt;? echo $row['billing_name']; ?&gt; &lt;br&gt;
              &lt;b&gt;Job Type:&lt;/b&gt; &lt;? echo $row['job_type']; ?&gt; &lt;br&gt;
              &lt;b&gt;Size:&lt;/b&gt; &lt;? echo $row['size']; ?&gt; &lt;br&gt;
              &lt;b&gt;Text:&lt;/b&gt; &lt;? echo $row['text']; ?&gt; &lt;br&gt;
              &lt;b&gt;Notes:&lt;/b&gt; &lt;? echo $notes; ?&gt; &lt;br&gt;
  
              &lt;br&gt;&lt;br&gt;
  
          &lt;form action="small_update.php" method="POST"&gt;
          &lt;strong&gt;Email Message:&lt;/strong&gt;&lt;br&gt;
          &lt;textarea rows="8" cols="60" name="email_message"&gt;&lt;/textarea&gt;        
          &lt;input type="submit" name="submit" value="Submit"&gt;&lt;/form&gt;
  
  
  &lt;?
  $email_message = htmlspecialchars ("{$_POST['email_message']}", ENT_QUOTES);
  
  
  if (mysql_errno() != 0) {
  die(mysql_error());
  }
  
  mysql_query(
  "UPDATE client_information
  SET email_message='$email_message'
  
  WHERE ID='$which_ad'"
  );
  
  
  if (mysql_errno() != 0) {
  die(mysql_error());
  }
  
      }
  
  ?&gt;
  </code></pre>