How to mount a select from DB

Asked

Viewed 34 times

0

Good afternoon, personal my doubt and the following I have a database that lists me all the dates of delivery of works as follows

2016-07-13
2016-07-01
2016-03-09
2015-09-09
2013-03-06

how do I mount two selects that contain only table data

being the year

2016
2015
2014

and a month according to the selected year and only the month it contains in that year

inserir a descrição da imagem aqui

  • When you say ride select refers to that select of html?

  • even added an image to clarify the question

  • 1

    Cool, now the situation is clearer. It has several things to do, the route is, 1) make a select in the database just returning the data column use the function year() to extract the year remember to group, so you have the list of years with delivery. 2) With javascript make an ajax call on onchange() of the year combo and send the value of the selected item. 3) this value goes in the where(with year()) query takes the result of ajax and populate the month combo with the values.

  • 1

    To take the month SELECT to_char(dia, 'MM') FROM tabela WHERE to_char(dia, 'YYYY') = '2016' GROUP BY to_char(dia, 'MM') and to catch the year SELECT to_char(dia, 'YYYY') FROM tabela GROUP BY to_char(dia, 'YYYY').

  • Thanks guys I’ll assemble here have an ajax code for state cities I will use it as a base

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.