| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Senior Member | Order Sub-Categories under Parent How will i be able to order my sub-categories under my parent? Right now they show up as: -Parent 1 -Parent 2 -Parent 3 -Parent 4 ---Sub-Categories of 1 ---Sub-Categories of 2 ---Sub-Categories of 3 ---Sub-Categories of 4 My code is: PHP Code: |
| |
| | #2 (permalink) |
| NamePros Regular | basic way: table looks like: category_id (int) category_name (Varchar) category_parent (int) PHP Code: Might have typos a bit, hard to code in this little box ;p Only good for 2 levels though THere's also traversal method which is very cool but not so basic Last edited by Noobie; 08-19-2006 at 02:34 PM. |
| |
| | #3 (permalink) |
| Senior Member | I Edited it to work with the way my table is setup: PHP Code: |
| |
| | #5 (permalink) |
| Senior Member | I just uploaded a screenshot of the part and the database: http://img217.imageshack.us/img217/7017/catrr7.gif |
| |
| | #7 (permalink) |
| Senior Member | This is the whole code for it... PHP Code: This is what the view source is showing for the drop down: Code: <select size="1" name="category" size="36" maxlength="255"><OPTION VALUE="NA" selected>Select A Category</OPTION><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option></select> <br><br> EDIT: i got it so the select values display the right id by adding $row = in front of the mysql_fetch_array, and also brought the number of options to the correct number, just trying to get it to display the category name now. EDIT: lol, stuiped me, was looking for the 'name' column when i changed it to 'title' in the databse. It works now, thanks alot! Last edited by killaklown; 08-19-2006 at 03:17 PM. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |