我想通过数据库传递url中的值来处理我的URL

So, I have user friendly urls for my website like this

www.quiz.com/quiz.php/category/subcategory/quiz

When a user tries to visit this page, I'd like to get the category, subcategory and quiz and process them so that I can get correct info. Now, by process I mean, I need to get these three values, run them through a databse to get their unique id's.

After getting these unique id's, I call a function using these values that will them get the correct information for the user. It's important to note that there are several categories, with several subcategories, and seveal subcategories with several quizzes under them.

Any ideas how I can do this?

EDIT: These urls don't actually exist, so a solution that works when a 404 error is expected back would be appreciated. Thanks.

I think this will help you

<?php 
$actual_url = "$_SERVER[REQUEST_URI]";

echo $actual_url;

$splitts = explode("/", $actual_url);


end($splitts);        
$key = key($splitts);



$quiz = $splitts[$key];
$subcategory = $splits[$key-1];
$category = $splitts[$key-2];