I have the following Category Table in my SQL Database. Every Category has a supercategory, every supercategory can have multiple subcategories.
CREATE TABLE Kategorien (
ID INT UNSIGNED AUTO_INCREMENT,
Bezeichnung VARCHAR(255) NOT NULL DEFAULT 'Bezeichnung',
PRIMARY KEY(ID),
Kategorien_ID INT UNSIGNED,
Bilder_ID INT UNSIGNED,
CONSTRAINT kidk FOREIGN KEY (Kategorien_ID) REFERENCES Kategorien(ID)
);
I want to fill the html select like this with php. So that the supercategory is an optgroup and the corresponding subcategories as options in that optgroup.
Picture of html select Example
How can i do this? What query should i send? How to fill the select with the data in php?