title: jQuery/PHP - detect which button is pressed
body: <p>I'm making some app (admin page), I loaded all users in <code>&lt;table&gt;</code>, also I have option to activate and deactivate each user. Now my problem is I don't know how to detect which 'activate' or 'deactivate' button is pressed, my code only works for first user in list. This is my code:</p>
  
  <p>adminPage.php:</p>
  
  <pre><code>&lt;?php
  $getData = $mysqli-&gt;query("select * from login");
  while($row = $getData-&gt;fetch_assoc()):
  ?&gt;
  &lt;tr id="dataRows"&gt;
      &lt;td id="firstTd"&gt;&lt;?php echo $row['user_id']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row['username']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row['email']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row['name']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row['lastname']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row['active']; ?&gt;&lt;/td&gt;
  &lt;?php if($row['active'] == 1){ ?&gt;
      &lt;td&gt;&lt;label id="userID" hidden&gt;&lt;?php echo $row['user_id']; ?&gt;&lt;/label&gt;
      &lt;label id="userActive" hidden&gt;&lt;?php echo $row['active']; ?&gt;&lt;/label&gt;
      &lt;label id="optionLabel"&gt;&lt;?php echo 'Deactivate'; ?&gt;&lt;/label&gt;&lt;/td&gt;
  
  &lt;?php } else{ ?&gt;
      &lt;td&gt;&lt;label id="userID" hidden&gt;&lt;?php echo $row['user_id']; ?&gt;&lt;/label&gt;
      &lt;label id="userActive" hidden&gt;&lt;?php echo $row['active']; ?&gt;&lt;/label&gt;
      &lt;label id="optionLabel"&gt;&lt;?php echo 'Activate'; ?&gt;&lt;/label&gt;&lt;/td&gt;
  
  &lt;?php } endwhile; ?&gt;
  </code></pre>
  
  <p>script.js:</p>
  
  <pre><code>$("#optionLabel").click(function(){
              $.post("option.php", {"id" : $("#userID").html(), "com" : $("#userActive").html()},
                  function(data){
                      if(data == "Updated"){
                          window.location.href = "adminPage.php";
                      }
                  }
              );
      });
  </code></pre>