lovephp Posted February 11, 2016 Share Posted February 11, 2016 Ianyone has some sample or could guide to a turorial on how to plan the tables structure and how to fetch the datas? Quote Link to comment https://forums.phpfreaks.com/topic/300783-how-to-create-category-subcategories-posts/ Share on other sites More sharing options...
Jacques1 Posted February 11, 2016 Share Posted February 11, 2016 You'll have to be a lot more specific. What exactly do you not understand? The basic structure should be obvious: There are categories, and there are posts. A category has a parent (which may be NULL for root categories), and a post belongs to one (or more?) categories. There's really nothing special. Note that if the number of subcategory levels isn't limited, fetching the category tree with MySQL will be a pain in the ass (since MySQL doesn't support recursive queries). But you can worry about that later. Quote Link to comment https://forums.phpfreaks.com/topic/300783-how-to-create-category-subcategories-posts/#findComment-1530999 Share on other sites More sharing options...
lovephp Posted February 11, 2016 Author Share Posted February 11, 2016 ok let me be more specific something like this url i am trying to acheive 1. category.php?name=shoes (this display all data from category shoes) category.php?name=watches (this display all data from category watechs) 2. category.php?name=shoes&area=casual (this display all data from casuals related to cat name shoes) category.php?name=shoes&area=watches (this display all data from casuals related to cat name watches) and lastly the product information display in some php file how do i plan this structure? Quote Link to comment https://forums.phpfreaks.com/topic/300783-how-to-create-category-subcategories-posts/#findComment-1531000 Share on other sites More sharing options...
Jacques1 Posted February 11, 2016 Share Posted February 11, 2016 So a product belongs to one category (or many categories?), and each category can be further divided into subsections like “casual”? If the “area” is really just an attribute of a product, I'd make three tables: categories, attributes (or areas) and products. Then you assign each product to one category and one attribute. If you need multiple categories or attributes, you need more tables. Quote Link to comment https://forums.phpfreaks.com/topic/300783-how-to-create-category-subcategories-posts/#findComment-1531019 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.