title: accept/decline submit buttons looping with php
body: <p>I'm trying to allow a user to accept/decline requests for an event through submit buttons. Information is looped and displayed in a row (username, location, accept,decline). </p>
  
  <p>Right now 2 users are being displayed; User 1 and User 2(current ones for testing). Anyway, I'm trying to get the correct userid to work with the correct username. Currently, regardless of which user I accept or decline, user 2 is displayed. I tried to set the value of the userid based on a hidden input but it's not working correctly. </p>
  
  <p>Here is my code.</p>
  
  <pre><code>for($i=0;$i&lt;count($userExplode)-1;$i++){
              $user = mysql_query("select userid,username from users where userid = ".$userExplode[$i]." ");
              $user = mysql_fetch_array($user);
              $userLoc = mysql_query("select userLocation from userinfo where userid = ".$userExplode[$i]." ");
              $location = mysql_fetch_array($userLoc);
              $locationExplode = explode("~",$location['userLocation']);
  
  //the displayed output is working correctly so I know it's setting $user['userid'] properly 
              echo '&lt;form method="post"&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="profile.php?userid=' . $user['userid'] . '"&gt;' . $user['username'] . '&lt;/a&gt;&lt;/td&gt;
                  &lt;td&gt;' . $locationExplode[0] . ', ' . $locationExplode[1] . '&lt;/td&gt;
                  &lt;td&gt;&lt;input type="hidden" name="userReq" value='.$user['userid'].'&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" name="accept" value="Accept Request" &gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" name="decline" value="Decline Request" &gt;&lt;/td&gt;&lt;/tr&gt;';   
              }
                  echo '&lt;/table&gt;&lt;/form&gt;';
          }
              if(isset($_POST['accept'])){
                  echo $_POST['userReq']; //displays user 2 even if I click user 1
                      }
              if(isset($_POST['decline'])){
                  echo $_POST['userReq']; //also displays user 2 even if i click user 1 
              }   
       }
  </code></pre>