Settingup forms/fields tables for linking data in front end?
I have a question/Answer table which holds values for Days, Months, Weeks, Years and various other data like this:
tbl_Questions
question_id questiontbl_answers
answer_id answertbl_QA
qa_id question_id answer_idSample day would be like:
Question:
23 - MonthsAnswers:
234 - Jan 235 - Feb 236 - March...QA:
100 - 23 - 234 101 - 23 - 235 102 - 23 - 236 ...All this is fine but I am lost on how do i pull (reference) this data into the front end forms? Obviously the months will be a drop down List on the site, so I want the drop down to pull in these values and I want these IDs to be written to the user table when they select a 'month' value for any question that has month. This way I can do analytic by having all data linked from 1 place. Any guidelines on how to go about this? Using mysql and php.
2) For months, do i need to store jan, feb, etc in seperate rows or can i seralize all data into one cell like "Jan", "Feb"... My concern is i need to开发者_运维技巧 do search on many of these lookup values so i dont know if i can do it within serialized text?
Pull the data from the database using a while loop and mysql_fetch_assoc in order to iterate over each question
<select>
while($row = mysql_fetch_assoc($result) {
$value = $row['question_id'];
$month = $row['question'];
echo "<option value='$value'>$month</option>";
}
</select>
The $result variables obviously being your DB query.
精彩评论