Hi,
I made a simple script in which i have categories etc. Its a multi category system in which user can go to any depth and for that my table structure is following:
Table: categories
id (Auto Number)
pid (medium int)
title (varchar 25)
I am using mod_rewrite to generate urls and displaying on web page. Please have a look at the following examples:
Category:
Computers/Internet
Games/Internet
So these are 2 different categories in 2 different parent categories. Now when someone click on the link it takes them to following respectively:
http://www.somedom.com/Computers/Internet
http://www.somedom.com/Games/Internet
and a show-category.php file is executed so it can display the list of websites in that category.
Now my question is how do i fetch the correct category using the URL above ? I use the following to fetch the url and split the cats/sub cats into an array:
Now how do i proceed further so i get the correct category id from the data of the particular id. If i try to do a simple lookup ion the db using the SELECT sql statement then the problem is that i end up getting wrong category.PHP Code:$category = explode ("/", substr($_SERVER['REQUEST_URI'], 1));
For example if user has selected Games/Internet but the Computers/Internet comes up first...so if i make a query like: SELECT * FROM categories WHERE title = 'Internet' then i will get the first record that is of Internet.
I hope i have described my problem. Please help me.
Thanks.




Bookmarks