flamerail Posted February 27, 2008 Share Posted February 27, 2008 Ok, So heres the simple development code. <select name="select"> <? $query = mysqli_query(core_db(),"SELECT * FROM article_cat WHERE parent_id = '0'"); while($cat = mysqli_fetch_array($query)){ echo '<option value="'.$cat['id'].'">'.$cat['name'].'</option>'; } ?> </select> article_cat is setup (ID | NAME | PARENT_ID) Essentially if the cat is parent_id 0 its the root level, and any sub level category sets parent_id as the category id before it, I have no Idea how to recursively loop this, Any ideas? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/93253-doing-a-recursive-category-system-stuck/ Share on other sites More sharing options...
aschk Posted February 27, 2008 Share Posted February 27, 2008 You have to LEFT JOIN the table to itself (however many times you want depth). Quote Link to comment https://forums.phpfreaks.com/topic/93253-doing-a-recursive-category-system-stuck/#findComment-477968 Share on other sites More sharing options...
flamerail Posted February 27, 2008 Author Share Posted February 27, 2008 I looked at some examples, Left Join is brutally slow and useless for what I need Quote Link to comment https://forums.phpfreaks.com/topic/93253-doing-a-recursive-category-system-stuck/#findComment-478589 Share on other sites More sharing options...
fenway Posted February 28, 2008 Share Posted February 28, 2008 I looked at some examples, Left Join is brutally slow and useless for what I need Shouldn't be... post the EXPLAIN. Quote Link to comment https://forums.phpfreaks.com/topic/93253-doing-a-recursive-category-system-stuck/#findComment-478791 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.