-6

Please solve it with database . https://prnt.sc/gp6x27 (please click here for clear view)

i am using database referrar_id (random number not 0 for parent id https://prnt.sc/gp6z0g) . need output like this screenshot

I am working on multilevel marketing on php Below is exiting database structure (look like) (in screen1 ) but i need display like screen2

Note : its dynamic if more subcategory then level increase and i am using parent key like in4907422 (it random number)

(screen1 below)

computer -hardware --mouse --keyboard -software --php ---core php ---magento ---opencart --java shoes -Nike --Red --White -Puma -Addas -Reebok Clothes -men --shirt --t'shirt -women

(screen2 below) (1 level) computer shoes clothes (2 level) hardware software Nike Puma Addas Reebok men women (3 level) mouse php java red white shirt'shirt (4 level) magento opencart


Thanks in advance

nagender
  • 1
  • 1

1 Answers1

0

you have two solutions here.

  1. If you are known to the number to categories and there respective depth like category > sub category >> sub sub category

then you can make different table with foreign keys.

  1. Create a categories table with following fields

    1. id
    2. name
    3. parent_id // nullable

here 1st level of categories will have no parent id, but the rest will have you can go as deeper as you like.

Moeen Basra
  • 733
  • 4
  • 18