GeorgeS
Posts: 206
|
| Posted: 11/03/2006, 12:20 PM |
|
Hi,
I have one listbox control the Form "Products"
This Listbox displays Names Categories and Sub Categories from the table "Categories"
Client asked me if it would be possible for Sub Categories to be indented like this inside the listbox:
----------------------------
Category 1
--SubCategory 1
--SubCategory 2
Category 2
--SubCategory 3
--SubCategory 4
I use ASP and PHP.
Any help would be appreciated.
_________________
GeorgeS |
 |
 |
wkempees
Posts: 1679
|
| Posted: 11/04/2006, 6:13 AM |
|
GeorgeS,
Without understanding your table structure, you could do this in the SQL underlying the Listbox.
You would have to manualy alter the SQL.
Based on the directory_categories table in the INTERNET sample database (MySQL)
SELECT CASE
WHEN category_id_parent is NULL then category_name
WHEN category_id_parent then concat('--',category_name)
END as category_name
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 11/04/2006, 6:35 AM |
|
To be more complete:
Based on the INTERNET sample database table directory_categories
SELECT category_id,
CASE WHEN category_id_parent is NULL THEN category_name
ELSE concat( '-- ', category_name)
END as 'category_name'
FROM directory_categories
order by concat( category_id, ifnull(category_id_parent, '00'))
would result in a Listbox displaying according to your needs AND have the correct id to use when an item is selected from the Listbox.
(Oh well, lazy Saturday)
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
|