Jump to content

Recommended Posts

Hi,

 

I'm making a stock control system and want some advice with the best way to do things.

 

Each of our products that we sell is actually made up of other components that we buy. I want to store the details for the components and for the piece that we sell, but there is no guarantee of how many pieces make a product.

 

I was thinking of storing them:

Sellable:

=============

Product ID

Description....

blah

blah

=============

 

Components

=============

Comonent ID

Sellable ID

Blah

Blah

=============

 

Which will work obviously, but I'm not sure what the best way to output the combined data would be. Would I need to use a JOIN? A "References"? (what does that do??)

 

Any and all help would be great. Thanks.

 

Andrew.

Link to comment
https://forums.phpfreaks.com/topic/135333-combining-data-from-multiple-tables/
Share on other sites

If I'm understanding what you what to do corrcetly then a few pointers that I would do are:

1: For your database structure->In the components table I would have a field called something like relating_product_id and this as its name suggests would hold the product ID that relates (foreign key) to that component. This will combat your one product to many components problem.

 

2: Then if you do the above you can select all components where there relating_product_id is equal to the product id you want to output in php script using a simple where = "" query.

 

:-)

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.