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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:23:09+00:00 2026-06-10T14:23:09+00:00

In my main PHP page I have a table in which i entered some

  • 0

In my main PHP page I have a table in which i entered some values to use as header. The code of that page is:

<form  method="post" action="<?php echo $_SERVER['PHP_SELF'] ;?>">
<table id="npc" cellspacing="10">
    <tr>
        <td> Building</td>
        <td> Level</td>
        <td> Lumber</td>
        <td> Clay</td>
        <td> Iron</td>
        <td> Crop</td>
    <tr>
</table>
</form>

I’m using jQuery and AJAX to call res.php.
The jQuery code is:

$.ajax(
                {

                    url: "res.php", 
                    type: "POST",
                    data: data,     
                    success: function (data) {
                        $('#npc').html(data);
                    }
                });

In the res.php page I am retrieving data from the database using the parameters that I have passed. Then I am displaying it in the table id="npc".

The contents of the res.php page are:

$result = mysql_query($query) or die('Error in Child Table!');

while( $data = mysql_fetch_assoc($result))
{
echo '<tr><td>'. $building. '</td><td>'. $level. '</td><td>'. $data['lumber']. '</td><td>'.$data['clay']. '</td><td>'. $data['iron']. '</td><td>'. $data['crop'].'</td></tr>';
} 

But for some reason instead of the data being appended to the end of the table id="npc" it is removing the previous data and then the new data is being displayed.

How do I keep the previous data and append the new data to the 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-10T14:23:10+00:00Added an answer on June 10, 2026 at 2:23 pm

    Instead $('#npc').html(data); try $('#npc').append(data);

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

Sidebar

Related Questions

I have some (php) code that performs critical updates on an InnoDB table. I'm
The Idea I have a main PHP page that loads content in DIV's from
I have a page (main.php) which loads content from an external PHP file (rpc.php).
I have a index.php page that is the main page. All pages are included
I have an PHP/HTML main page, in which I include different other PHP files
For eg I have this code on the main page. <?php session_start(); $_SESSION['order']=array(); ?>
I'm trying to make a dynamic table with PHP. I have a page which
I have a simple php page, with the main content placed in a table
I have 2 files, main.html and search.php . Within the main.html page, there is
I'm developing web page which has main file index.php as follows: include('UserClass.php'); include('html/top.php'); $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.