First let see the table structure 2. Assuming you have done database connection 3.Create Recursive Function 4. And now display Tree/Hierarchy structure category’s by calling Recursive Function 5. Create a function that update the sort-order and parent id in database through AJAX 6. Call the {update_category_id} function