简体   繁体   English

根据行值一次填充下拉列表

[英]Populate dropdown based on row values one time

Hey guys I have a table that I built, but I am trying to add some stuff into it. 大家好,我有一张桌子,但我想在桌子上加些东西。 I want to have a dropdown gets populated based on the dates that are in the database. 我想根据数据库中的日期填充下拉列表。

This is how my db looks: 这是我的数据库的外观:

http:// i.imgur.com/YKgjf4C.png http:// i.imgur.com/YKgjf4C.png

I want it to show the dates from pat_date a single time and only the ones that are in the database, skipping the ones that aren't there, and limiting the so called duplicates it to 1 date per line, bascially not listing like 07/11/2013 about 14 times. 我希望它一次显示来自pat_date的日期,并且仅显示数据库中的日期,跳过那些不存在的日期,并将所谓的重复项限制为每行1个日期,基本上不会像07 / 11/2013约14次。

_________________
| SELECT DATE |v|
-----------------
|  07/02/2013 | |
|  07/08/2013 | |
|  07/11/2013 | |
--------------| |

How am I able to do this with my current script? 如何使用当前脚本执行此操作?

Right now I have it like this 现在我有这样

http:// i.imgur.com/r0zCrDj.png http:// i.imgur.com/r0zCrDj.png

but its annoying going through every date, and instead would be easier if i could already have the dates with a dropbox i know has some people scheduled on it. 但是它烦人的经历了每个日期,如果我已经有了一个带有保管箱的日期,而我知道有人安排了它,那么它将变得更容易。

How is this possible? 这怎么可能?

you can use a distinct query 您可以使用不同的查询

SELECT distinct `date` from `yourtable`;

I would also suggest you storing your dates as a date field, this will make sorting and manipulating based on those values much easier. 我还建议您将日期存储为日期字段,这将使基于这些值的排序和操作更加容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM