Hi everyone
I have a form where users can submit sites and say if they work in different browsers. Currently, it looks like this:
<input type=checkbox name="browsers[]" value="IE6"/>Internet Explorer 6<br/>
<input type=checkbox name="browsers[]" value="IE7"/>Internet Explorer 7<br/>
<input type=checkbox name="browsers[]" value="IE8" checked="checked"/>Internet Explorer 8<br/> <br/>
<input type=checkbox name="browsers[]" value="FF2" checked="checked"/>Firefox 2<br/>
<input type=checkbox name="browsers[]" value="FF3" checked="checked"/>Firefox 3<br/> <br/>
<input type=checkbox name="browsers[]" value="SA3" checked="checked"/>Safari 3<br/>
<input type=checkbox name="browsers[]" value="SA4" checked="checked"/>Safari 4<br/> <br/>
<input type=checkbox name="browsers[]" value="CHR" checked="checked"/>Chrome<br/> <br/>
<input type=checkbox name="browsers[]" value="OPE" checked="checked"/>Opera<br/> <br/>
<input type=checkbox name="browsers[]" value="OTH" />Other Browsers<br/> <br/>
What I want to know is, what's the most efficient way of storing checkbox values in a database? When a user browsers to the site's page on my site, I want it to query the database and return which sites it's compatible with. Currently I'm thinking of doing it with something like this:
<?php if (!$browsers['FF2'] = NULL) {
//(Insert into field named 'FF2')
} else {
//(Keep field named 'FF2' as NULL)
} ?>
Then when visiting the site's page, it would just check through each database column (FF2, FF3, SA4, etc.) to see if the value isn't NULL. If not, it'll echo 'Compatible with FF2' etc.
This strikes me as being slightly illogical. Having a seperate column for each browser seems a little funny - I don't know if this is me being skeptical or if that really is the easiest way to go about it. Can anyone suggest some other methods?
Thanks!
Jack