justlukeyou Posted May 15, 2012 Share Posted May 15, 2012 Hi, I have a database of products but I am finding it diffult to understand how to categorise each product and build a site for it. Can I do something like this: $category = ( $gamesconsoles = ( playstation, xbox, wii ) $personalhygiene = ( electric toothbrush, electric razor, electric shaver) ) So I have PHP code which identifies a 'Playstation' as a $gamesconsoles. It then enters a 'gamesconsoles' tag into the database in a category field. I then I have link on my site which looks something like this on the homepage: productrange.php?category="gamesconsoles" class="menulink">Games Consoles</a> I then link to a productrange.php page which has in it: $category = category; if (isset($_GET['category'])) { $id = $_GET['category']; } I then echo all the producys from the database which come under the category of 'gamesconsoles'. Or am I completely mad and it should be done differently. If so please advise. Quote Link to comment https://forums.phpfreaks.com/topic/262574-creating-a-product-categorising-system/ Share on other sites More sharing options...
wigwambam Posted May 15, 2012 Share Posted May 15, 2012 Why not create a category and a sub-category? In the product table, you could have something like: id category subcategory product name price etc.... 1 Consoles Playstation Sony PS2 99.99 2 Consoles Playstation Sony PS3 299.99 3 Consoles XBOX XBOX 199.99 4 Hygiene Razor 5 Hygiene Shaver... etc... To make it more efficient, you could have a separate category/subcategory table and link via ids. Quote Link to comment https://forums.phpfreaks.com/topic/262574-creating-a-product-categorising-system/#findComment-1345710 Share on other sites More sharing options...
justlukeyou Posted May 15, 2012 Author Share Posted May 15, 2012 Many thanks, thats definately what I am looking to do. However I am confused as to how categorise products. How do tell my Database that an Xbox should be go under a consoles category? Quote Link to comment https://forums.phpfreaks.com/topic/262574-creating-a-product-categorising-system/#findComment-1345711 Share on other sites More sharing options...
ignace Posted May 15, 2012 Share Posted May 15, 2012 wigwambam already showed you: id category subcategory product name price etc.... 3 Consoles XBOX XBOX 199.99 Quote Link to comment https://forums.phpfreaks.com/topic/262574-creating-a-product-categorising-system/#findComment-1345713 Share on other sites More sharing options...
justlukeyou Posted May 15, 2012 Author Share Posted May 15, 2012 Many thanks, But how does the database know to put Sony PS2 in the sub-category for 'Playstation'? Would I need PHP script to do this? Quote Link to comment https://forums.phpfreaks.com/topic/262574-creating-a-product-categorising-system/#findComment-1345715 Share on other sites More sharing options...
The Letter E Posted May 15, 2012 Share Posted May 15, 2012 Why not create a category and a sub-category? In the product table, you could have something like: id category subcategory product name price etc.... 1 Consoles Playstation Sony PS2 99.99 2 Consoles Playstation Sony PS3 299.99 3 Consoles XBOX XBOX 199.99 4 Hygiene Razor 5 Hygiene Shaver... etc... To make it more efficient, you could have a separate category/subcategory table and link via ids. Agreed Quote Link to comment https://forums.phpfreaks.com/topic/262574-creating-a-product-categorising-system/#findComment-1345743 Share on other sites More sharing options...
justlukeyou Posted May 16, 2012 Author Share Posted May 16, 2012 Many thanks, I am still a bit confused as to how to designate a 'Sony PS2' as a product within the subcategory Playstation which is labelled as a Subcategory of Consoles. Is it best to do this in the Cron Job? Quote Link to comment https://forums.phpfreaks.com/topic/262574-creating-a-product-categorising-system/#findComment-1345865 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.