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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:58:32+00:00 2026-06-13T22:58:32+00:00

Currently I am pulling data out of a database to build a table dynamically.

  • 0

Currently I am pulling data out of a database to build a table dynamically. After pulling the data, I want myself and or my users to be presented with an option (button) where if they click the button I can edit/remove this row from the table as well as from the database.

I am new to jQuery so I am not sure what I should use for the $.ajax() functionality.
This is my php code:

foreach($stmt as $item){

            echo '
            </td>
            <td>'.$item['asin'].'</td>
            <td>'.$item['weight'].'</td>
            <td>'.$item['dimension'].'</td>
            <td>'.$item['category'].'</td>
            <td>';

                    echo '<button type="button" class="btn">Update Me!</button>';

            echo '
            </td>
        </tr>';
    }
    echo '</tbody>
    </table>';

This is my jQuery code:

      $(document).on('click', '.btn', function() {
    $.ajax({
    //code here etc
    success:function(){
    //what to put here?
    }

});
}
  • 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-13T22:58:33+00:00Added an answer on June 13, 2026 at 10:58 pm

    All of this is paraphrased – you should be able to get the answer from here. At least well enough to try something and post a fuller example.

    1) Each table row needs to have an identifier that the javascript can grab. You may find this easier with a data_ element

    PHP has:

    echo '<button type="button" class="btn" data_id="'.$item['asin'].'">Update Me!</button>';
    

    JS has:

    $(document).on('click', '.btn', function() {
       var id = $(this).attr('data_id');
       ...
    

    2) You need a PHP function that returns update data for that row

    <?php
    
        if (isset($_GET['id'])) {
             $id = $_GET['id'];
             $item = Get Data From Where Ever
             echo '<td>'.$item['asin'].'</td>
                   <td>'.$item['weight'].'</td>
                   <td>'.$item['dimension'].'</td>
                   <td>'.$item['category'].'</td>
                   <td><button type="button" class="btn" data_id="'.$item['asin'].'">Update Me!</button></td>';
        }
    
     ?>
    

    3) Use javascript / ajax to get the data

    $(document).on('click', '.btn', function() {
        var id = $(this).attr('data_id');
        var self = $(this);
        $.ajax({
           url: 'MyUrl?id=' . id;
           success:function(data){
               $(self).html(data);
           }
        });
    }
    

    It’s not perfect, you’ll need to worry about making stuff safe, error checking etc, but that should give you the leg up you need.

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

Sidebar

Related Questions

I currently am pulling menu data out of our database using the PDO fetchAll()
I am currently working on a project where i am pulling out data using
I am pulling records out of my mysql database using php and want to
I'm pulling data out of a Google doc, processing it, and writing it to
I am pulling my hair out with this one. I have a table inside
I'm creating a caching system to take data from an SQLite database table using
I am currently pulling an XML feed into a webapp through ajax. Obviously i
I'm currently pulling emails from an exchange inbox like so... var exchangeService = new
Im pulling a text file - it will be input by user currently its
I'm working currently on a long polling script where i've to check a database

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.