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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:33:57+00:00 2026-06-10T23:33:57+00:00

I have a table filled with data from my database, and i want a

  • 0

I have a table filled with data from my database, and i want a button next to it for each specific user to delete that user. but how do i do this?

Here’s the code:

<?php               
    include '../includes/db_connect.php';

    $sql = "SELECT * FROM `users`";
    $result = mysql_query($sql, $connection) or die ("Failed to excecute the query $sql on $connection");
?>
<table border=1>
    <tr>
        <th>
        Access lvl
        </th>
        <th>
        Username
        </th>
        <th>
        Email
        </th>
    </tr>
<?php
    while($row = mysql_fetch_array($result))
    {
        echo "</td><td>";
        echo $row['access'];
        echo "</td><td>";
        echo $row['username'];
        echo "</td><td>";
        echo $row['email'];
        echo "</td></tr>";
    }
    echo "</table>";
?>
  • 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-10T23:33:58+00:00Added an answer on June 10, 2026 at 11:33 pm

    I do this very often and use jQuery for it. I use the following:

    HTML:

    <table>
    ....
    <tr>
        <td><span class="delete">Delete me!</span></td>
    </tr>
    </table>
    

    jQuery:

    $(document).on("click", ".delete", function(event)
    {
        var sData = "?id=" + $(this).data("id");
        $.ajax({
            url: "pages/delete_script.php",
            type: "POST",
            data: sData,
            success: function(sResult)
            {
                // Process the data you got back from the delete script
                // For example removing the row if successfully deleted:
                if(sResult == "OK")
                {
                    $(this).closest("tr").remove();
                }
            },
            statusCode: 
            {
                404: function() 
                {
                    alert("page not found");
                }
            }
        });
    });
    

    The on() is for the dynamic elements (I do everything with AJAX on that page). Then I put the data I need to send in the correct format and do the AJAX request. In the PHP file could be this:

    if($_SERVER['REQUEST_METHOD'] == "POST")
    {
        if(isset($_POST['id'])
        {
            mysql_query(
                sprintf('DELETE FROM `table` WHERE `id` = %d', $_POST['id'])
            );
        }
    }
    

    Of course it’s recommended to use more checks to make sure you remove the right one.

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

Sidebar

Related Questions

I have a table that is filled with data from a database. When you
I have a page with a dynamic table, filled with data from mysql database.
Hy!! I have a listview that should be filled with data from the database
Let's say I have a dynamically-created table that is filled with data from a
I have a data table filled with text in each table row. How do
I have a C# List, that is filled from a database.. So far its
I have a JTable filled with data of a table of my database (so
I have a list that i fill with data from a database, and now
I have a table with records from a database which is dynamically filled. <table>
I have a table cell that isn't entirely filled with text so the bg

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.