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 8352541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:59:24+00:00 2026-06-09T08:59:24+00:00

I am writing a script that allows users to create teams, send contracts to

  • 0

I am writing a script that allows users to create teams, send contracts to others that are registered, so on and so forth. I want the logged in user to be able to withdraw from a team. The html tables are dynamically populated from mysql using php. I can get it to apply my delete option to all the users within the <td></td> but not just the one that is logged in. Here is some code snippets to help I hope. Basically I want only the user that is logged in to have the delete option.

    Id   Player
    1    User 1 - No Delete Option
    2    User 2 - Delete Option (Is the logged in user)
    3    User 3 - No Delete Option

    session_start();
    $get_users_name = $_SESSION['username_u'];

    $sql = ("SELECT id, username FROM user WHERE username='$get_users_name'");
    $result = mysql_query($sql) or die(mysql_error());

    while ($row = mysql_fetch_array($result)) {
    $grab_id = $row['id'];
    $grab_user = $row['username'];

//the rest of the table generation done here such as <tr> etc

    echo "<td>";
    if ($grab_user == $get_users_name) { 
    echo '<a href="user_delete.php?id='.$grab_id.'" onClick="return confirm(\'Are you sure you want to withdrawl from the team?\')">'.$grab_user.'</a>';
    } 
    else
    { 
    echo $grab_user;
    }
    echo "</td>";

//the rest of the table generation done here such as </tr> etc

}

**Edited to fix echo problem caught by @easteregg

  • 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-06-09T08:59:26+00:00Added an answer on June 9, 2026 at 8:59 am

    Just be sure you will style your code for readability ,then you will notice that you have your if condition inside the echo 😉

    Try this it should work!

    echo "<td>";
    
    if ($grab_user == $get_users_name)  {
        echo '<a href="user_delete.php?id='.$grab_id.'" onClick="return confirm(\'Are you sure you want to withdrawl from the team?\')">'.$grab_user.'</a>';
    } else {
        echo $grab_user;
    }
    
    echo "</td>";
    

    Be aware of the fact, that you should check again in the user_delete.php if a user has the right to delete something , otherwise you will run into some strange sort of trouble 😉

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

Sidebar

Related Questions

I'm writing a semi-automated deploy script that allows users to tag the repository at
I'm writing a PHP script that allows the user to download a file. Basically
I'm writing an app that allows you to script the buttons from a wiimote
I'm writing a script that asks the user for several options and then, via
I'm writing a script that will allow a user to input a string that
I'm writing a webapp that basically allows users to kick off shell scripts with
I am writing a fairly simple MVC3 application that allows a user to retrieve
I'm writing a script that allows me to do some basic imposition within InDesign
I'm writing a script in Python that will allow the user to input a
I'm writing a web page that has a from field that allows a user

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.