| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: Oct 2003
Posts: 3,472
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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 ????: NamePros.com http://www.namepros.com/programming/229487-order-sub-categories-under-parent.html -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 Join Date: Feb 2006 Location: Montreal, Quebec, Canada
Posts: 324
![]() | 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 03:34 PM.
|
| |
| | THREAD STARTER #3 (permalink) |
| Senior Member Join Date: Oct 2003
Posts: 3,472
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | I Edited it to work with the way my table is setup: PHP Code: |
| |
| | THREAD STARTER #5 (permalink) |
| Senior Member Join Date: Oct 2003
Posts: 3,472
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | I just uploaded a screenshot of the part and the database: http://img217.imageshack.us/img217/7017/catrr7.gif |
| |
| | THREAD STARTER #7 (permalink) |
| Senior Member Join Date: Oct 2003
Posts: 3,472
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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!
__________________ hostvouchers - Coupons and Reviews for the top web hosts! (shared, reseller, vps, servers, adult, offshore, proxy)
Last edited by killaklown; 08-19-2006 at 04:17 PM.
|
| |