CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Formatting content of a ListBox control

Print topic Send  topic

Author Message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.