|
Posted by Jim S. on 02/05/06 04:33
sorry ZeldoreBlat, i did not mean to neglect u, but the same response that i
said to J.O. applies here to.
"ZeldorBlat" <zeldorblat@gmail.com> wrote in message
news:1139097269.517377.257710@f14g2000cwb.googlegroups.com...
>
> Jim S. wrote:
>> hey guys and gals,
>> here is my problem:
>> i have a form, and recently my crazy mind decided to make 5 select/menus
>> that belong to the same field ("features"),(each select/menu has many
>> options, that is why i chose the select menu not, an another way)
>>
>> SO: the options for "features" field are let us say: (menu value)
>>
>> smart 1, happy 2, crasy 3 , depressed 4, frustrated 5, lazy 6, dumb 7
>>
>> now, the user has to choose 4 from them,
>>
>> So: i made 5 select/menus to select from (each one at a time)
>>
>> so far so good, if u are still reading, am impressed and i really thank
>> you
>> :)
>>
>>
>> now here is what i did:
>> i named every select/menu "features[]"
>> and i used implode to get the values to a variable $all like this:
>>
>> $all = implode(",", $HTTP_POST_VARS['features']);
>>
>>
>> i succeeded to have the value ( for my example) 0,0,0,0,5,0,0
>> now i want to get the value of $all in the database, (so i can spit it
>> out
>> later with an "echo" or something)
>> i made a field in the database with ENUM, with the "list" inserted in
>> it
>> sequetially
>>
>> Question: am i doing it right, what am i doing wrong, and where can i go
>> from there?
>>
>> if u have a better suggestion please do not hesitate to suggest with some
>> "code"
>>
>> thanks
>> Jim
>
> Why not have a single select list that allows multiple selections?
> Write your <select> tag like this: <select name="features[]"
> multiple="multiple">. Now the user can select more than one. On the
> page where you process the form, $_POST['features'] will be an array
> containing each of the selections (like you had before).
>
> I wouldn't implode the list before putting it in your database.
> Instead you should normalize things as follows:
>
> A table user (uid, name, etc.)
> A table features (fid, name, etc)
> A table userFeatures (uid, fid)
>
> This does two things. To indicate that a user made a selection, insert
> a row in userFeatures with the user's uid and the feature's fid. This
> also gives you a list of the choices in your database somewhere so you
> don't need to hard-code them on the pages to make the select lists.
>
Navigation:
[Reply to this message]
|