Hey Why don't you make a second table 'categories' and have the two tables in relation? For example:
Table 'contacts': id name category_id ------------------------------ 0 John Doe 3 (Category "New York Office") 1 Jane Smith 4 (Category "Orlando Office") 2 Mark Jones 2 (Category "Creative") Table 'categories': id name parent_id ------------------------------ 1 Sales 0 (Main category) 2 Creative 0 (Main category) 3 New York Office 1 (Subcategory of "Sales") 4 Orlando Office 1 (Subcategory of "Sales") So you have unlimited subcategories and the users can choose and add them easily. In addition, you have normalized your data... cheers Marcel On Fri, 18 Jun 2004 16:29:14 -0400 Monty wrote: > Hi, I need to add the ability for users to define and set up their own > categories and sub-categories that can be used to group contacts they enter > into a database. Here's an example of how the data might be stored... > > > Name Main Category Sub Category > ------------- ----------------- ---------------- > John Doe Sales New York Office > Jane Smith Sales Orlando Office > Mark Jones Creative > Sarah Williams Creative > Kevin Brown Manager Office Manager > Joe Johnson Manager Site Manager > > > I need to allow users to define the types of Main Categories they want, and > to also define whether or not those Main Categories will have Sub > Categories, which they can also define. > > I know how to do this if the types of categories and sub-categories were > pre-defined, but, I'm finding it a lot trickier to allow the users to > customize these with their own category types. So, I'm hoping someone might > be able to point me to an example of how custom categories and > sub-categories can be programmed in PHP and set up in MySQL. > > Any suggestions or advice would be much appreciated! > > Monty > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- Marcel Tschopp <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php