设置表单/字段表以在前端链接数据?

发布于 2024-10-07 23:29:33 字数 690 浏览 0 评论 0原文

我有一个问题/答案表,其中包含天、月、周、年的值以及各种其他数据,如下所示:

tbl_Questions
Question_id
问题

tbl_answers
答案 ID
回答

tbl_QA
qa_id
Question_id
answer_id

示例日如下:

问题:
23 个月

答案:
234 - 一月
235 - 二月
236 - 三月...

QA:
100 - 23 - 234
101 - 23 - 235 102 - 23 - 236 ...

这一切都很好,但我不知道如何将这些数据拉(引用)到前端表单中?显然,月份将是网站上的下拉列表,因此我希望下拉列表可以提取这些值,并且当用户为任何包含月份的问题选择“月份”值时,我希望将这些 ID 写入用户表中。这样我就可以通过从 1 个位置链接所有数据来进行分析。有关如何进行此操作的任何指导方针?使用mysql和php。


2)几个月来,我是否需要将一月,二月等存储在单独的行中,或者我可以将所有数据序列化到一个单元格中,例如“一月”,“二月”...我担心的是我需要对其中许多数据进行搜索查找值,所以我不知道是否可以在序列化文本中执行此操作?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清欢 2024-10-14 23:29:33

使用 while 循环和 mysql_fetch_assoc 从数据库中提取数据,以便迭代每个问题

<select>
while($row = mysql_fetch_assoc($result) {
   $value = $row['question_id'];
   $month = $row['question'];
   echo "<option value='$value'>$month</option>";
}
</select>

$result 变量显然是您的数据库查询。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文