Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7441277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:59:09+00:00 2026-05-29T10:59:09+00:00

I’m trying to allow a user to accept/decline requests for an event through submit

  • 0

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).

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.

Here is my code.

for($i=0;$i<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 '<form method="post"><table><tr><td><a href="profile.php?userid=' . $user['userid'] . '">' . $user['username'] . '</a></td>
                <td>' . $locationExplode[0] . ', ' . $locationExplode[1] . '</td>
                <td><input type="hidden" name="userReq" value='.$user['userid'].'></td>
                <td><input type="submit" name="accept" value="Accept Request" ></td>
                <td><input type="submit" name="decline" value="Decline Request" ></td></tr>';   
            }
                echo '</table></form>';
        }
            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 
            }   
     }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:59:09+00:00Added an answer on May 29, 2026 at 10:59 am

    There is a lot wrong with your code:

    • You don’t close the for‘s in the loop
    • there is no action on your form
    • you’re starting a new table for each loop

    Replace the submit button’s by anchors and add the parameters in there. Then you can style the anchor to look like a button.

    <input type="submit" name="decline" value="Decline Request" >
    

    becomes

    echo "<a href="yourfile.php?userid=".$user['userid'].">Decline request</a>";
    

    Remove all the <form>s and load everything in 1 table.

    Result:

    <?php
    if(isset($_GET['action']) AND isset($_GET['userid'])){
    
        switch($_GET['action']){
            case "accept":
                // do whatever
            break;
            case "decline":
                // do whatever
            break;
            default:
                die('something wrong');
            break;
    
        }
    
    }
    
    echo '<table width="100%">';
    
    for($i=0; $i <= count($userExplode); $i++){
      $q = "
            SELECT u.userid,u.username, userLocation
              FROM users u
        INNER JOIN userLocation ul ON u.userid = ul.userid 
             WHERE u.userid = ".$userExplode[$i]."
      ";
      $rs = mysql_query($q) or die(mysql_error());      
      $user = mysql_fetch_array($rs);
    
      $locationExplode = explode("~",$user['userLocation']);
    
      //the displayed output is working correctly so I know it's setting $user['userid'] properly 
      echo '<tr><td><a href="profile.php?userid=' . $user['userid'] . '">' . $user['username'] . '</a></td>'.
           '<td>' . $locationExplode[0] . ', ' . $locationExplode[1] . '</td>'.
           '<td><a href="yourfile.php?userid=' . $user['userid'] . '&action=accept">Accept Request</a></td>'.
           '<td><a href="yourfile.php?userid=' . $user['userid'] . '&action=decline">Decline Request</a></td></tr>';   
    
     }
    
    echo '</table>';
    

    I think this is only the tip of the iceberg.. How do you get $userExplode for example? It is very weird and illogical. I assume that you first run a query to get all the users and then loop with this for?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.