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

  • Home
  • SEARCH
  • 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 1098727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:37:22+00:00 2026-05-17T00:37:22+00:00

I am using the jQuery plugin from http://mjsarfatti.com/sandbox/nestedSortable/ It does an excellent job on

  • 0

I am using the jQuery plugin from http://mjsarfatti.com/sandbox/nestedSortable/
It does an excellent job on easily sorting the list, but I am having issues with saving it a DB and loading it back up.

My question is once you get the array into PHP, serialize it and store it into a database, you end up with something along the lines of

a:1:{s:4:"page";a:4:{i:4;s:4:"root";i:2;s:1:"4";i:3;s:1:"2";i:1;s:1:"2";}}

Pulling it back out of the database, unserialize it and do a var_export I have

array ( 'page' => array ( 1 => 'root', 3 => 'root', 2 => '3', 4 => 'root', ), )

How do I then go through this array and make sure each child is correctly nested?
The output should be in an unordered list like

page_1
page_3
 - page_2
Page_4

Or in real code

<ul>
  <li id="page_1">Page 1</li>
  <li id="page_3">Page 3
    <ul>
      <li id="page_2>Page 2</li>
    </ul>
  </li>
  <li id="page_4">Page 4</li>
</ul>

But once finished it will be huge and possibly 4-5 levels deep.

Thanks in advance!

  • 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-17T00:37:23+00:00Added an answer on May 17, 2026 at 12:37 am

    This should get you on your way:

    function display_page_listings($arr, $parent = 'root')
    {
        if($parent == 'root')
        {
            echo '<ul>';
        }
        $displayed = false;
        foreach($arr as $item_index => $item_parent)
        {
            if($item_parent == $parent)
            {
                if(!$displayed && $parent != 'root')
                {
                    echo '<ul>';
                    $displayed = true;
                }
                echo '<li id="page_' . $item_index . '">Page ' . $item_index;
                display_page_listings($arr, $item_index);
                echo '</li>';
            }
        }
        if($parent == 'root' || $displayed)
        {
            echo '</ul>';
        }
    }
    
    $arr = array(
        'page' => array ( 1 => 'root', 3 => 'root', 2 => '3', 4 => 'root')
    );
    
    display_page_listings($arr['page']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the jQuery Autocomplete plugin from http://docs.jquery.com/Plugins/Autocomplete on IE7 and it's not releasing
I am using the jQuery mask plugin from http://digitalbush.com/projects/masked-input-plugin/ I want to customize my
I'm using the jquery autocomplete plugin from pengoworks: http://www.pengoworks.com/workshop/jquery/autocomplete_docs.txt In the function called upon
I'm using hashchange jQuery plugin from http://benalman.com/projects/jquery-hashchange-plugin/ to hook up an event when the
I'm using the jQuery positioning plugin from jQuery UI: http://wiki.jqueryui.com/w/page/12138026/Position Positioning works well enough
I'm using the jQuery Simple Drop-Down Menu Plugin from http://javascript-array.com/scripts/jquery_simple_drop_down_menu/ In their example, when
i'm using the validation plugin from http://docs.jquery.com/Plugins/Validation i'd like to know if it is
I have a problem , i'm using jQuery plugin from http://www.stilbuero.de/jquery/tabs/ , plugin for
I am using the jquery validation plugin from: http://bassistance.de/jquery-plugins/jquery-plugin-validation/ How can I add a
I'm using the validate plugin from http://bassistance.de/jquery-plugins/jquery-plugin-validation/ What i'm trying to find is a

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.