title: Update Single DB Record, Using PHP While Loop
body: <p>I feel like there is an easy solution to this problem yet I can not figure it out. I am displaying the fields of my database using a while loop. At the end of each while loop is a form input where the admin can approve users. (All approved needs to do is change a 1 to a 2 in the approved column of that specific record).</p>
  
  <p>All of the Approved records get changed instead of the specific one that I want. My question is how can I select and change only one record at a time. (The record in which gets approved). Thank you so much for any help you can provide me.</p>
  
  <pre><code>    &lt;?php
        //select the database to write to
        $unapprovedTeachers = mysql_query("SELECT * FROM members_teachers WHERE approved = '1'", $dbc) or die("Could not select the unapproved teachers at this time.");
          //While loop to cycle through the rows
          while($row = mysql_fetch_assoc($unapprovedTeachers)){
              $teacher_id = $row['id'];
              echo $teacher_id;
      ?&gt;
      &lt;ul class="admin-fields"&gt;
      &lt;?php
          foreach($row as $field){
              if(empty($field)){
                  echo "....";
              }
              print '&lt;li&gt;' .$field.' &lt;/li&gt;';
          }//End For Each Loop
          //print $teacher_id;
  
  
      ?&gt;
              &lt;/ul&gt;
      &lt;footer&gt;
       &lt;?php
          if(isset($_POST['approve'])){
          mysql_query("UPDATE members_teachers SET approved = '2' WHERE id= ".$teacher_id."", $dbc) or die ("Oops something went wrong");
      }
        ?&gt;
          &lt;ul&gt;
              &lt;li&gt;
                  &lt;form method="post"&gt;
                          &lt;button name="approve" id="approve" type="submit"&gt;approve&lt;/button&gt;
                  &lt;/form&gt;
                 &lt;/li&gt;
         &lt;/ul&gt;
     &lt;/footer&gt;
     &lt;!--End New Row--&gt;
    &lt;/section&gt;
        &lt;?php
      }//End While Lopp
      mysql_close($dbc);
         ?&gt;
     &lt;/div&gt;
  </code></pre>