Results 1 to 3 of 3
Jun 16, 2007, 07:19 #1
- Join Date
- Jun 2005
- 0 Post(s)
- 0 Thread(s)
populating form menus conditionally
I have a form which will allow me to populate a garments table within my database. Among the elements in the form, there is a suppliers drop down menu and a categories multiple select menu. I used the following code to populate these menus.
// this code always runs, and gets lists of suppliers and garment categories
$getSuppliers = 'SELECT * FROM suppliers ORDER BY supplier';
$suppliers = $db->query($getSuppliers);
$getCategories = 'SELECT * FROM categories ORDER BY category';
$categories = $db->query($getCategories);
I guess you'd need to know a bit about the database structure for this: The garment types have their own table with its primary key also in the garments table as a foreign key. Since the supplier_id also exists in the garments table as a foreign key, I guess the connection between these two could be made.
The sizes and colours each have their own table and there's also garment_to_colour and garment_to_size lookup tables. These lookup tables contain the garment_id primary key from the garments table as well as the respective colour_id and size_id foreign keys from each of their tables.
I just wondered if someone could show me what the code might look like, in one of these scenarios?
Really appreciate any help offered.