Re: Subcategories in php

From: Date: Sat, 20 Sep 2003 14:51:37 +0000
Subject: Re: Subcategories in php
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-163294@lists.php.net to get a copy of this message
I have been trying to do this for weeks but i just cant figure this out. I have categories that have subcategories and i want to insert them into database. My table looks like this: cat_id, parent_id and cat_name. Let's say i wanna insert a subcategory that is associated with its parent category.
If I understand your situatoin, I would create two tables: categories (category_id, category_name) subcategories (subcategory_id, category_id, subcategory_name) Then, in your PHP script, have the user select the category and enter the subcategory name. The SQL INSERT would then be INSERT INTO subcategories (category_id, subcategory_name) VALUES ($cat_id, '$subcat_name'); Larry

« previous php.general (#163294) next »