简体   繁体   中英

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

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.

_________________
| 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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