Example ..
Is it possible for the user to check both the 3-door and the 5-door
at the same time? Or will your script supposed to be a selection between
the two. I have the same question for all other choices also.
I'm thinking you need a chain-style selection to select one from each category?
Maybe we need to know what your script (or website) is going to be used for?
This is for a backend area of a car dealership website..
This check box area Is to make it easier to add the options to the vehicles.. So it does not matter what the choice.. As long as it is in the database and can be pulled out for reference to the vehicle and can be changed on a whim.
Currently I was thinking a array into the database but not sure what the structure should be for storing the options.
I have the car in a different database and will reference the two with the vehicle stock number that I have in the vehicle DB. Just need t figure out these annoying checkboxes.
The main point about how to handle the database tables would be the ability
to add, delete, or modify the various options. That's going to be a big deal.
You want this to be flexible enough for changes without modifying everything.
So now, you're at the point of determining a way to accomplish a "normalized"
database, and yet make this thing easy to manage. You should really hope now
that other forum programmers offer some advice ... I believe we are all going to
come-up with different ideas and opinions on this topic.
One idea ...
Give each group a category number, and each option within that group a sub-category number.
So you have a table that contains the list of all categories and sub-categories.
Your rows are added in any order, each row getting a unique ID when the row is inserted.
You can add more, delete them, modify them, change info, etc. and once the
change is made, the list of checkboxes will change automatically because PHP
is using this table to create your page of checkboxes. It loops by category and
by sub-category.
You have another table that adds a row for each item assigned to a VIN number.
This table will get to be really huge. Maybe you could create a table
for each VIN? The name of the table would be the VIN number?
The queries would now be done by first searching for the VIN,
then within that result, join the categories and subcategories of
one table to the other so you can get a comprehensive result
of the options for that VIN.
The key point to all of this is the PHP script using the database to create your
page of checkboxes. As it creates the actual HTML list, the value of each checkbox is
the category|subcategory.
When submitted, the PHP script processes the array called checks[] and
knows which checkboxes were checked and knows which category and
subcategory was checked for each one.
I guess you could do it that way.
When a row is created, make all columns zero (0).
For checkbox values, make them 1.
You'll see the problem though ... the reason I gave my original answer ...
You're going to have to hand-code 90 different checkboxes in your HTML
form, and read those 90 checkboxes. If you decide to add an option, you'll
have to edit your HTML form, your PHP script, and your database table.
It doesn't matter what you make the column values ...
It does matter how you develop the scheme for reading checkboxes.
Add a row for each item per VIN (like I described) and then
delete all rows with the matching VIN when you're done with it.
That will keep the table size manageable.