You should really look into database normalization.
With your current table structure, there's no efficient way to do what you need (because you only have one field for storing each type of component.
A workaround would be to convert each field that could potentially hold multiple user selections to a JSON type and store them there. (all it takes would be to build a $monitors
array and then convert it to json (with json_encode($monitors)
prior to inserting. This, while feasible, has some drawbacks in terms of efficiency and indexability/searchability
what you really need is, like I said earlier, normalizing your tables.
You should have a "pivot" table (let's call it "assemblies") and separate component tables (call them what you want, but it could be "monitors", "cpus", "memory" etc).
When assembling a new device, you'd create a new "assembly" and insert the components in their respective table with a reference to the master "assemblies" table
By doing this, you could have a single assembly referencing multiple entries in the "monitors" table because this structure allows establishing "one-to-many" relationships
I strongly suggest you get your feet wet with normalization. Wikipedia could be a good starting point HERE
A more in depth explanation with examples can be found HERE
monitors
where all monitors are stored and a tablesystem_units
(your existing table). Now you need an another table called (for example)system_unit_monitors
. There you store the id of the system unit table and the monitor table to connect it with each other. – thmspl Nov 13 '19 at 7:52