Hi everyone,

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.

PHP Code:
// this code always runs, and gets lists of suppliers and garment categories
$db=new Database('localhost','root','password','catalogue',0);
$getSuppliers 'SELECT * FROM suppliers ORDER BY supplier';
$suppliers $db->query($getSuppliers);
$getCategories 'SELECT * FROM categories ORDER BY category';
$categories $db->query($getCategories);
There is also a colours menu, a sizes menu, and a garment type menu in the form. Instead of having these populate with the entire contents of their respective tables, I wanted to have each of them populate conditionally according to which supplier was chosen, ie. if a particular supplier was chosen, each of the menus mentioned would contain data specific to that supplier.

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.