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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:08:37+00:00 2026-06-11T22:08:37+00:00

I am fairly new to Javascript, and Ajax in particular so bear with me…

  • 0

I am fairly new to Javascript, and Ajax in particular so bear with me…

I want to have a table updated after inserting a new row, but instead of having the Ajax output an html table all together, I’d much prefer to collect all the data from the PHP mysql and insert it into a pre-existing table with a loop.

This is how I would usually do it using PHP and a while() function so that I can insert various parts of data using an array. For eg "$mem['Name']"

    $mems = mysql_query($sql,$con);
    while($mem=mysql_fetch_array($mems)){
                $lmc++;


                            echo '<tr class="data">';
                                echo '<td class="index">'.$lmc.'</td>';          
                                echo '<td class="name">'.$mem['Name'].'</td>';
                                echo '<td class="arcid">'.$mem['ArcID'].'</td>';
                                echo '<td class="type">'.$mem['Type'].'</td>';
                                echo '<td class="role">';
                                echo '<input style="width:100%;" type="text" name="art_realname" id="art_realname" class="field" value="'.$mem['Role'].'"   tabindex="1" />';
                                echo '</td>';
                            echo '</tr>';
                        };

Is there any way of using AJAX so that I can firstly collect all the data in the PHP file and put it in an array, then secondly send it back to the AJAX, and then finally do the loop section using Javascript on the actually page and insert it into the tables there?

  • 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-11T22:08:38+00:00Added an answer on June 11, 2026 at 10:08 pm

    This solution requires jQuery, but you are free to use any JS framwork/lib.

    Also, you should know that using the mysql_* functions is a bad idea as they are going to be deprecated soon.

    Now, let’s assume you have a script named ajax.php on your server. You should go about querying your database in the same way as always, but instead of echoing it – put in a variable.

    <?php
    /* your script here */
    $data = ... /* data your query returned */
    
    header ("Content-Type: application/json" );
    echo json_encode ($data);
    ?>
    

    Then on the client side:

    $.getJSON ( "ajax.php", function (data) {
       /* data is the $data from your PHP script */
    });
    

    You are not an idiot 🙂

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

Sidebar

Related Questions

I'm fairly new to facebook development, but have experience with PHP and JavaScript. I've
I am fairly new to php and mysql but I have created a small
I'm fairly new to JavaScript/jQuery/AJAX, so I suspect the issue is some typo I'm
I am fairly new to AJAX so please forgive me. I have to forms
I am fairly new to JavaScript and I want to create objects and arrays
I'm fairly new to the whole JQuery/javascript world, but I've managed to wack together
I am fairly new to jQuery and JavaScript in general. I have a form,
I am fairly new to Jquery and javascript and have jumped in head first
Hi guys, I'm fairly new to javascript. I have a pretty simple script I
I'm fairly new to javascript and I'm trying to make an form for my

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.