あなたのデータベース構造は、親に関連するIDを含み、管理パネルでselectboxの親カテゴリとサブ親カテゴリを取得する必要があります
USE `database`;
CREATE TABLE `category` (
`c_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`category_name` varchar(255) DEFAULT NULL,
`status` enum('active','inactive') DEFAULT 'active',
PRIMARY KEY (`c_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;
/*Data for the table `category` */
insert into `category`(`c_id`,`category_name`,`status`) values (1,'For Sale','active'),(2,'Community','active'),(3,'Classes','active'),(4,'Vehicles','active'),(5,'Real Estate','active'),(6,'Services','active'),(7,'Matrimonial','active'),(8,'Jobs','active');
CREATE TABLE `sub_category` (
`sub_cat_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`c_id` int(11) DEFAULT NULL,
`sub_category_name` varchar(255) DEFAULT NULL,
`status` enum('active','inactive') DEFAULT 'active',
PRIMARY KEY (`sub_cat_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
/*Data for the table `sub_category` */
insert into `sub_category`(`sub_cat_id`,`c_id`,`sub_category_name`,`status`) values (1,1,'Animals','active'),(2,1,'Art - Collectibles','active'),(3,1,'Books - Magazines','active'),(4,1,'Business - Industrial','active'),(5,4,'Cars','active'),(6,4,'Truck','active');
/*Table structure for table `sub_category_child` */
CREATE TABLE `sub_category_child` (
`sub_category_child_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`c_id` int(11) DEFAULT NULL,
`sub_cat_id` int(11) DEFAULT NULL,
`sub_category_child_label` varchar(255) DEFAULT NULL,
`nature` varchar(20) DEFAULT NULL,
`status` enum('active','inactive') DEFAULT 'active',
PRIMARY KEY (`type_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;
insert into `sub_category_child`(`sub_category_child_id`,`c_id`,`sub_cat_id`,`sub_category_child_label`,`nature`,`status`) values (1,4,5,'Make','parent','active'),(2,4,5,'Model','child','active'),(3,4,5,'doors','independent','active'),(4,4,5,'accessories','independent','active'),(5,1,1,'abc','parent','active'),(6,4,6,'No of Tyre','parent','active'),(8,4,6,'loader','independent','active');