Recursively check the parents of a child in a database
I'm working on a CMS system that receives urls like this: /parent1/parent2/child/ Now it's easy to check only the child but in my opinion you should also check if the parents are correct and in the right order. The problem is that I'm unsure on how to do this. I'm using mysql. this is how that table would look: CREATE TABLE IF NOT EXISTS `pages` ( `id` int(11) NOT NULL auto_increment, `parent` int(11) NOT NULL default '0', `title` varchar(255) NOT NULL, `deleted` tinyint(1) NOT NULL default '0', PRIMARY KEY (`id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; the parent field keeps