开发者

Settingup forms/fields tables for linking data in front end?

开发者 https://www.devze.com 2023-01-31 03:55 出处:网络
I have a question/Answer table which holds values for Days, Months, Weeks, Years and various other data like this:

I have a question/Answer table which holds values for Days, Months, Weeks, Years and various other data like this:

tbl_Questions

question_id

question

tbl_answers

answer_id

answer

tbl_QA

qa_id

question_id

answer_id

Sample day would be like:

Question:

23 - Months

Answers:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消