Page 1 of 1

Structure of DB for CMS ideas

Posted: Wed Nov 23, 2011 11:20 am
by zero477
Hello everyone,

I have a long list of standard features of some products (90 features 1800 products) which I am integrating in a CMS. I have to elaborate a CREATE, READ and MODIFY section for the products and I was thinking of using check boxes and if statements with 90 columns in my DB for each feature. (I hope there is an easier way to do this)

Before I typed in all the features in one column and splited it with the previous functions mentioned, but it doesn't work for the modify section of the CMS.

I am trying to learn a method in which I can easily integrate this 90 standard features in the CMS. Does anyone has a good idea?

Re: Structure of DB for CMS ideas

Posted: Wed Nov 23, 2011 11:53 am
by twinedev
One method would be to create a table of all the features, then for each product have field with a list of all the ID's for the features it has. When I have to do something like that, I store it as such:

~3~9~13~44~74~

This way if I need to search for a specific one, I can do WHERE `features` LIKE "%~13~%" to grab it.

So on the page to create an item, you would have an array of all 90 features, so you can loop through displaying them, then when you are done, take the array of ones selected and do: $features_field = '~'.implode('~').'~';

To read it back in (for display or to edit: $aryFeatures = explode('~',trim($features_field,'~'));

NOW, that being said, with how many items you have, depending on how you will be using them all, you may want to just have a third table that consists nothing of ProductID and FeatureID. Those are two simplistic ways I can think of off the top of my head.