...

View Full Version : how to divide input?



Tomek
07-29-2006, 02:13 PM
hi
i'm new to mysql, and would like help with something
i'm making a script with which u can create your own polls, and the problem is displaying the answers to choose from

my idea was to enter answers in a textarea dividing them with "enter" (1 in each row) and later, to divide the entry by searching for "/n". the problem is that i don't know how to do that :(
help, anyone?
thx in advance

raf
07-29-2006, 03:55 PM
why don't you just create a seperate record for each alternative?

Tomek
07-29-2006, 04:53 PM
i thought about that...
wouldn't i need a new table for each question that way?
this seemed like a better idea
and i've seen it working on ipb forum

raf
07-29-2006, 10:06 PM
i thought about that...
wouldn't i need a new table for each question that way?

no. in a normalised db, you would have a table for the questions, like
questionID | question_text | createdattime | ...

and then you would have a table with all your alternatives for all questions. Like
alternativeID | questionID | alternatie_text | num_votes | createdatime | ...


this seemed like a better idea
and i've seen it working on ipb forum
well, go ahead and set it up like you see fit. but i've learned that using composit values soner or later gets you into trouble. to be honest: using composit values is almost always a beginners mistake...

if you don't wanna normalise your db and store all alternatives in one field, then it would also be better to store the alternatives as a serialized array.

Tomek
07-30-2006, 01:37 AM
no. in a normalised db, you would have a table for the questions, like
questionID | question_text | createdattime | ...

and then you would have a table with all your alternatives for all questions. Like
alternativeID | questionID | alternatie_text | num_votes | createdatime |
jeez that's nice :)
thanks a lot :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum