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! 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). 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 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. 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
Archived
This topic is now archived and is closed to further replies.