I've been struggling with 2 problems when creating a CMS where I want to implement friendly urls, using PHP5 and MySQL 5.
The basic database structure is as follows:
------------------------------- | ID | PageName | ParentID | ------------------------------- | 1 | Page1 | 0 | | 2 | Page2 | 0 | | 3 | SubPage1 | 1 | | 4 | SubSubPage1 | 3 | -------------------------------
I then want to generate urls like the following:
Page with ID=1 will have URL: /Page1
Page with ID=3 will have URL: /Page1/SubPage1
Page with ID=4 will have URL: /Page1/SubPage1/SubSubPage1
When visiting the page I have a .htaccess rule to dispatch the url to a querystring like: ?page=/Page1/SubPage1 etc
How can I query the database to compare the URL with the database entries?