It calls for a intermediate table.

You need 3 tables:
pf_survey, categories and survey_cat

They look like:
pf_survey
survey_id, Questions, Whatever, but no categories fields

categories
category_id, category_name

survey_cat
survey_id and category_id

for each record in pf_survey you will have one or more records in
survey_cat. Each record in servey_cat will be one of the tick boxes ticked
for that survey_id... so 2 tick boxs, 2 records in survery_cat with the
same survery_id...

When accessing the data you will need to use some different SQL querys
like the JOIN, and/or select more than one table at a time...

This is the correct database relationship way of doing it, but if this is
beyond you a cheap and nasty was would be to either:
A)store a comma delimited list of cat_id in your pf_survey record.
B)create a boolean field for each catorgy in your pf_survey table..

Hope this helps
Andrew

----- Original Message -----
From: "Duffy Betterton" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 28, 2002 2:48 PM
Subject: [PHP] Does this call for an array?


> Here is what I would like to do. I have a simple form that asks for
> information from a customer. One of the questions is Which categories of
> products are you interested in? I want to store all the data in a table
> called pf_survey. All the categories(42) are already listed in a
> separate table called categories. I don't think I want to repeat a list
> of columns in the pf_survey table if they are already in the categories
> table. The categories table is simply category_id and category_name. If
> my form has a checkbox by each category name with the corresponding
> category_id in the value field - how do I concatenate all the boxes
> checked in order to put more than one category_id in the pf_survey
> category_ids field?
>
> Does this call for an array? Does it even make sense to do it like this?
> Thank you for any help.
>
> Duffy Betterton
> Director of Publications
> 615-277-3265
> [EMAIL PROTECTED]
> www.mtadistributors.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to