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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:31:05+00:00 2026-05-25T00:31:05+00:00

I have a PHP file running a number of queries, storing the sets of

  • 0

I have a PHP file running a number of queries, storing the sets of results in multidimensional associative array and encoding as JSON like so:

{"1":{"name":"Bob","score":18},"3":{"name":"Robert","score":12},"4":{"name":"Terry","score":22}...}

So the array contains a set of arrays with ID numbers as keys, each containing the elements ‘name’ and ‘age’.

I am serving some HTML like this:

<div id="game1">high scorer: Bob<br />score: 18</div>
<div id="game3">high scorer: Robert<br />score: 12</div>
<div id="game4">high scorer: Terry<br />score: 22</div>

And I want the info in these divs to update according to the JSON string as served by the PHP, so if the scores have been beaten to update with the new information.

I have tried using .get() and .load() but not really sure what to do to extract the elements from the JSON and disperse them to the divs.

  • 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-05-25T00:31:06+00:00Added an answer on May 25, 2026 at 12:31 am

    How about using getJSON() method of jQuery?

    $.getJSON('path/to/page.php', function(data) {
      $.each(data.myJSONArray, function(key, val) {
        $("#yourDiv").append('<div id="' + key + '">' + val + '</div>');
      });
    });
    

    http://api.jquery.com/jQuery.getJSON/

    Edit: You would need to tweak the implementation slightly so that it matches your jSon data structure – what I’ve added above is based on a generic name/value pair structure within the jSon data.

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

Sidebar

Related Questions

I have a PHP file with shell commands running through a screen, the commands
I have a PHP File with something like this: <script type=text/javascript> var page =
I have a PHP file that contains a large array (about 90KB). I'm considering
I have a php file list.php <?php $arr=array('444','555'); echo var_export($arr); ?> Now I want
I have a php file which has some variables like $name1, $name2... How can
I have a PHP file which will return something like <div id=title>Add Us On
I have a php file that echos JSON encoded arrays, the contents of which
I have a PHP file that's running a simple check for currency conversion. It
I have a php file 'run.php' which I'm running from the terminal. Within this
I have my xampp instalation up and running. I have a php file with

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.