PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Feb 24, 2020 10:33 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Nov 23, 2011 12:20 pm 
Offline
Forum Newbie

Joined: Wed Nov 23, 2011 12:17 pm
Posts: 4
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?


Top
 Profile  
 
PostPosted: Wed Nov 23, 2011 12:53 pm 
Offline
Forum Regular
User avatar

Joined: Tue Sep 28, 2010 11:41 am
Posts: 984
Location: Columbus, Ohio
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group