Jump to content

Auto Nested Categories from Flat File


natasha_thomas

Recommended Posts

Folks,

 

I have a flat file or CSV, which has the tree structure of the Nesed Categories (All are delimited by either > or tab, it can be set easily).

 

I want a PHP/Mysql code/routine that i can automaticaly create a table in MYsql with Parent Child relationship.

 

Logic is there in my mind, every distinct Node will be an ID which while every child node will have the PID (parent ID) of its Parent.

 

 

So the below data from flat file (Actual Data can be N Level Deep at least 4 Level):

 

 

Electronics
Electronics > Phones 
Electronics > Phones > Iphone
Electronics > Phones > LG
Electronics > Phones > Samsung
Electronics > Phones > Samsung > 3G


Electronics > Laptops
Electronics > Laptops > Dell
Electronics > Laptops > Sony
Electronics > Laptops > HP
Electronics > Laptops > HP > Core 2 Duo

 

 

 

Will look like this in Mysql Table Structure:

 

 

 

This is the Logic i need ot adopt, but i have no clue on how to code it to extract in this table structure and define this paren tchild mapping automatically.

 

Can someone Help me out wiht this?

 

 

 

Cheers

Natasha T

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.