Ok,I havent a clue how to do this. I have a mysql table for products, each has id as the primary key.
I have an admin page where I upload products to this table or delet/hide them too.
But I want a way where when I'm uploading the products to the table I can pick 2 or 3 other products from the table so I can put them as avalible options in the product listing.

For example the product listing is for a remote control car, there would be a checkbox underneath for adding 4AA batteries to the order.

I hope I made that clear?

Can anyone help me on this?

Thanks
Glen

Recommended Answers

All 3 Replies

Member Avatar for iamthwee

Have two tables... One with the items and the id.
The other table will list all available options

So you do a join on the id to list all the available options

Product table

+------+-----------+
| id   | name      |
+------+-----------+
|  1   |  car      |
+------+-----------+

Options table

+------+-----------+
| id   | options   |
+------+-----------+
|  1   |  battery  |
+------+-----------+
|  1   |  doors    |
+------+-----------+
|  1   |  windows  |
+------+-----------+

Thanks. I had thought of doing that, but even that would confuse me!!

Would there be any way of choosing the option from my existing table? As all the products will be in there anyway and the options are also stand alone products...

Member Avatar for iamthwee

You could potentially list all the options in the same table. And when you do the select statement you just select by the product name. This would avoid needing any join types in your SQL however, this is strongly NOT advised.

Partly because it contravenes the standard practice of 'normalising' your databases. Which in layman terms means removing mass duplication.

In the long run, it will speed up your db queries and will actually be easier to maintain.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.