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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:50:27+00:00 2026-05-24T11:50:27+00:00

heres the function: http://pastebin.com/tQLjzzbH I want it to return this: {years:[ { yName:2011, yAlbums:[

  • 0

heres the function:
http://pastebin.com/tQLjzzbH

I want it to return this:

{"years":[
    {
        "yName":"2011",
        "yAlbums:[
            {
                auID:"1234",
                aID:"456",
                etc..
            },
            {
                auID:"12345",
                aID:"4567",
                etc..
            }
    },
    {
        "yName":"2010",
        "yAlbums:[
            {
                auID:"2234",
                aID:"556",
                etc..
            }
    }
]}

but its only returning this:

{"years":[
{"yName":"2011"},
{"yName":"2010"}]}

Been trying to get this for ages, am totally lost now. Some help would be appreciated.

Thanks.

  • 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-24T11:50:28+00:00Added an answer on May 24, 2026 at 11:50 am

    You have read your result to the very end by

    while($data2 = mysql_fetch_assoc($result))
    {
        $yearsArrayRaw[] = $data2['album_year'];
    }
    

    Add mysql_data_seek($result,0) before inner while, to line 36. Also, I would suggest rewriting this function to have single loop, using something like

    $year_albums= array();
    while ($data = mysql_fetch_assoc($result)){
        if (empty($years[$data['album_year']])){
            $year_albums[$data['album_year'] = array(
                'yName'=>$data['album_year'],
                'yAlbums'=>array()
            );
         }
         //...album creation logic here...//
         $year_albums[$data['album_year']['yAlbums'][] = $album;
    }
    //Converting arrays into objects
    $years = array();
    foreach ($year_albums as $year){
        $years[] = (object)$year;
    }
    json_encode($years);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As documented here: http://www.jblotus.com/2011/05/24/keeping-your-handlebars-js-templates-organized/ I am trying to use this function: ( function getTemplateAjax(path,
http://pastebin.com/1MGTtzij here is my full html document, and below is the short version: $(document).ready(function
So I've got this code already: http://pastebin.com/3wuFNWGA And I've got these typedefs in a
I have configured my zend navigation menu like Config: http://pastebin.com/B212uWKz public function _initNavigation() {
In here, http://jsfiddle.net/sjKgF/78/ JS CODE $('.display_box').hover(function (){ $(this).attr('class', 'display_box current') }, function (){ $(this).attr('class',
I've created a hierarchical main menu with drupal 7, looks like this: http://dl.dropbox.com/u/16019885/Unbenannt.PNG Now,
I'm trying to compile a C program, with these headers: http://pastebin.com/SppCXb0U , on Ubuntu.
full code here... http://pastebin.com/EEnm8vi3 line 378 is not inserting the sections into the current
I'm been trying to wrap javascript try/catch as seen on http://pastebin.com/f579d999d It works well,
i have a problem with displaying GoogleMap. Here is the website source code: http://pastebin.com/LjhVbEF7

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.