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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:49:15+00:00 2026-05-31T12:49:15+00:00

I have this JSON code: { phrases: [ { phrases: [ { id: 33,

  • 0

I have this JSON code:

{
    "phrases": [
        {
            "phrases": [
                {
                    "id": "33",
                    "text": "sasdsad",
                    "date": "2012-03-14 20:28:45",
                    "views": "0",
                    "ip": "64.191.90.5",
                    "reported": "0",
                    "strange": "0",
                    "lang": "en"
                },
                {
                    "id": "32",
                    "text": "que ondaa\r\n",
                    "date": "2012-03-14 20:27:45",
                    "views": "0",
                    "ip": "64.191.90.5",
                    "reported": "0",
                    "strange": "0",
                    "lang": "en"
                },
                {
                    "id": "31",
                    "text": "dsadssadsad",
                    "date": "2012-03-14 20:27:35",
                    "views": "0",
                    "ip": "64.191.90.5",
                    "reported": "0",
                    "strange": "0",
                    "lang": "en"
                }
            ],
            "details": {
                "success": "true",
                "phrase_id": "",
                "phrase_text": "",
                "phrase_date": ""
            }
        }

I don’t really know what to do. I get some phrases vía MySQL, and pushes them to an array. This array is json_encoded() and gets printed.

$sth = $sql;
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
    $rows[] = $r;
}
$sth = $sql;
$data = array(
    "success" => "true", 
    "phrase_id"      => "",
    "phrase_text"      => "",
    "phrase_date"      => "",
);
    print json_encode($rows).json_encode($data);

and with jQuery I was trying to parse it, but I can’t. This is the main problem.

function getPhrases(order,limit,last){
    var req_url = ...;
    $.getJSON(req_url, function(data) {
        $.each(data.phrases, function(i, data) {
            appendPhrase(data.text);
            lastid = data.id;
        });
        $.each(data.details, function(i, data) {
            $("#phrases-count").html(data.totalcount);
        });
    });
}

PS: I was doing this with “echo” but got some problems.

{
    "phrases": [
        {
            "id": "33",
            "text": "sasdsad",
            "date": "2012-03-14 20:28:45",
            "views": "0",
            "ip": "64.191.90.5",
            "lang": "en"
        },
        {
            "id": "32",
            "text": "que ondaa<br />",
            "date": "2012-03-14 20:27:45",
            "views": "0",
            "ip": "64.191.90.5",
            "lang": "en"
        },
        {
            "id": "31",
            "text": "dsadssadsad",
            "date": "2012-03-14 20:27:35",
            "views": "0",
            "ip": "64.191.90.5",
            "lang": "en"
        }
    ],
    "details": [
        {
            "totalcount": "3",
            "logged_in": "false"
        }
    ]
}
  • 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-31T12:49:16+00:00Added an answer on May 31, 2026 at 12:49 pm

    You can’t simply combine these JSON arrays:

    print json_encode($rows).json_encode($data);
    

    Try this (attempt 2):

    print json_encode( array('phrases' => $rows, 'details' => $data) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code $('div#create_result').text(XMLHttpRequest.responseText); where the content of XMLHttpRequest is responseText: Content-Type: application/json;
I have this code in an HTML page: alert(JSON.stringify(new Date())); I'm including the latest
I have this code: $coder = JSON::XS->new->utf8->pretty->allow_nonref; %perl = $coder->decode ($json); When I write
I have this code: $.getJSON('http://www.reapp.se/cmesapp/cmes.json?callback=?', function(data){ alert(disco); }).error(function() {alert(fail!;}); Which is sending out an
I have this piece of code: @RequestMapping(value = /test.json, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public
I have this block of code that eventually get serialized to JSON, for use
Say i have this short code: item = Item.find(params[:id]) render :json => item.to_json but
I have this Json code: { term : { PrincipalTranslations : { 0 :
I have this piece of code: this.json.each(function(obj, index) { var li = new Element('li');
I have this code: function getTime(zone, success) { var url = 'http://json-time.appspot.com/time.json?tz=' + zone,

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.