Jump to content

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.

wigwambam already showed you:

id    category        subcategory        product name          price      etc....

3    Consoles      XBOX                  XBOX                    199.99

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.