Jump to content

Creating A Product Categorising System


justlukeyou

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/262574-creating-a-product-categorising-system/
Share on other sites

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.