eugene2009 Posted November 13, 2009 Share Posted November 13, 2009 So i got this part figured out.. CREATE TABLE category( category_id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20) NOT NULL, parent INT DEFAULT NULL); INSERT INTO category VALUES(1,'ELECTRONICS',NULL),(2,'TELEVISIONS',1),(3,'TUBE',2), (4,'LCD',2),(5,'PLASMA',2),(6,'PORTABLE ELECTRONICS',1), (7,'MP3 PLAYERS',6),(8,'FLASH',7), (9,'CD PLAYERS',6),(10,'2 WAY RADIOS',6); SELECT * FROM category ORDER BY category_id; My question is now.. how do I generate html pages where PAGE 1 (ELECTRONICS) Televisions Portable Electronics PAGE 2 (DEPENDING ON PAGE 1 SELECTION) .. Lists here all the childs of electronics.. PAGE 3 ..Lists the subcategory of previous page. Does anyone know what im talking about? PLEASE HELP Link to comment https://forums.phpfreaks.com/topic/181344-categorizing/ Share on other sites More sharing options...
pastcow Posted November 13, 2009 Share Posted November 13, 2009 SELECT p.name as parent_name, c.* FROM category AS p LEFT JOIN category AS c ON c.parent=p.category_id ORDER BY c.parent; This should give you each category and its parents name Link to comment https://forums.phpfreaks.com/topic/181344-categorizing/#findComment-956928 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.