Jump to content

Find/Get Root


The Little Guy

Recommended Posts

I am going to build a function that gets an id from a table.

I have a second table that has categories, with three columns:

+ id + parent + name +

 

the id passed to the function will match the id column from above, then that id will have a parent id, which matches another row from the same table as the above three columns, and so on and so forth.

 

Basically I want to loop through this until parent equals 0, and there is more than one parent that equals 0  in the table (I have three at the moment).

 

So, lets say I pass 10 to the function, the returned MySQL row would be:

+ 8 + 0 + Internet +

 

if I pass "3" to it, I would get:

+ 2 + 0 + Windows +

 

 

parent of one row equals id of another row in the same table.

 

I hope that all makes sense...

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.