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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:34:33+00:00 2026-05-13T15:34:33+00:00

I want to integrate an async treeview in PHP. Now i want to know

  • 0

I want to integrate an async treeview in PHP. Now i want to know how to generate a source php file with PHP.

Now my database structure is like this:

Create table School(
id int(10) NOT NULL AUTO_INCREMENT, 
name varchar(50), 
primary key(id)
);
Create table Class(
id int(10) NOT NULL AUTO_INCREMENT,
name varchar(50), 
school_id int(10), 
primary key(id), 
foreign key(school_id) reference School(id) on delete cascade
);
Student(
id int(10) NOT NULL AUTO_INCREMENT, 
name varchar(50), 
class_id int(10),
primary key(id), 
foreign key(class_id) reference Class(id) on delete cascade
);



School -> Class -> Student

Now, i want to realize the treeview. Do you have any ideas of implementing it?

Thanks a lot.

Additional question: When i finish the treeview. If i click the items in the treeview, it will generate a result table by clicking. Do you know how to do that?

However, firstly i should finish the treeview.

  • 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-13T15:34:33+00:00Added an answer on May 13, 2026 at 3:34 pm

    So basically you need to (pseudo code):

    $tree = array();
    /**
     * the following line essentially executes the Query:
     * SELECT * from schools;
     * and returns all the rows in an array like 
     * $schools = Array(0=>array('id'=>1, 'name' => 'name'))
     */
    $schools = $db->schools()->selectAll();
    
    foreach($schools as $school)
    {
       $schoolArr = array('text' => $school['name']);
    
       /**
        * Similar to the calls to school above except the query would be:
        * SELECT * from class where class.school_id = $school['id']
        * $school['id'] is the pk from the particular school record
        */
       $classes = $db->classes()->select("school_id = ?", $school['id']);
       $classesArr = array();
       foreach($classes as $class)
       {
          $classArr = array('text' => $class['name']);
          /**
           * Similar to the calls to school above except the query would be:
           * SELECT * from student where student.class_id = $class['id']
           * $class['id'] is the pk from the particular class record
           */
          $students = $db->students()->select('class_id = ?', $class['id']);
          $studentsArr = array();
          foreach($students as $student)
          {
              $studentsArr[] = array('text' => $student['name']);
          }
    
          $classArr['children'] = $studentsArr;
          $classesArr[] = $classArr;
       }
    
       $schoolArr['children'] = $classesArr;
       $tree[] = $schoolArr;
    }
    
    $jsTreeString = json_encode($tree);
    

    Now obviously as you go through each loop you need to be assinging your other tree properties. then when youre all done just json_encode the array and echo it where i needs to be. At least thats how id work it. Note though, that you can probably do this without an individual query using some joins but i didnt want to get into all that – youll definitely wann explore that though if performance is at all an issue.

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

Sidebar

Related Questions

I want to integrate my flash file with php code. I got the below
I want to integrate the MySQL fulltext search function in my PHP site. I
I want to integrate the zxing source code to my Android application. I have
We have a proprietary framework and now we want to integrate the authentication by
I want to integrate the services of escrow.com in my PHP site. How would
I want to integrate a report writer in our web application. Right now ,
I have a questing regarding MSMQ... I designed an async arhitecture like this: CLient
I want to integrate Alfresco with Moodle. I would like Moodle users to be
I want to integrate billdesk payment gateway in my php website. So that i
I want to integrate the Facebook chat system in my PHP based website. I

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.