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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:18:00+00:00 2026-05-25T21:18:00+00:00

I insert several( array ) value with json_encode in one row from database table,

  • 0

I insert several(array) value with json_encode in one row from database table, now want echo they as order with jquery.

This is output from my PHP code:

[{
    "guide": null,
    "residence": [{
        "name_r": "jack"
    }, {
        "name_r": "jim"
    }, {
        "name_r": "sara"
    }],
    "residence_u": [{
        "units": ["hello", "how", "what"],
        "extra": ["11", "22", "33"],
        "price": ["1,111,111", "2,222,222", "3,333,333"]
    }, {
        "units": ["fine"],
        "extra": ["44"],
        "price": ["4,444,444"]
    }, {
        "units": ["thanks", "good"],
        "extra": ["55", "66"],
        "price": ["5,555,555", "6,666,666"]
    }]
}]

I want as(output):

jack
hello & 11 & 1,111,111
how & 22 & 2,222,222
what & 33
& 3,333,333,

jim
fine & 44 & 4,444,444

sara
thanks & 55 & 5,555,555
good & 66 & 6,666,666

How is it?

  • 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-25T21:18:01+00:00Added an answer on May 25, 2026 at 9:18 pm

    Assuming

    • you already know how make the ajax request that fetches this information from your PHP script
    • there is always one element in the top-level array (if not, you could add one more level of iteration)
    • by output you mean access the corresponding elements – I’ve put in calls to console.log but you could alert() or put into a DOM element or whatever

    you could do something like this in jQuery (here’s an example fiddle without the network part. You’ll see the output in your console)

    var data = response[0]; //response is the data received by the jQuery ajax success callback
    var residences = data.residence;
    var residence_u = data.residence_u;
    
    $.each(residences, function(index, val){
        var name = val.name_r;
        console.log(name);
    
        var info = residence_u[index]; //get the corresponding residence_u element
    
        $.each(info.units, function(index, val){
            var unit = val;
            var extra = info.extra[index];
            var price = info.price[index];
            console.log( val + " & " + extra + " & " + price);
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I insert several( array ) value with json_encode in one row from database table,
I'm trying to insert several newly created items to the database. I have a
I need to insert data from several tables with all the same field names
I have an HTML Table consisting of several rows. I am trying to insert
Summary: Given an array {a, b, ..., w, x, ..., z} insert several elements
Using the Mysql multi insert statement (Inserting several records in one INSERT statement). Is
My question is how does one abstract a database connection from the model layer
I need to retrieve data from several rows and then insert the results into
I use jQuery to add a new input. Each row in table contains several
I have a long running insert transaction that inserts data into several related tables.

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.