timstring;11021383 wrote:Each one depends on the other.
Not really; the only field that has a dependency on previous selections is the "Day" field. You don't need to supply a year to get the name of a given month, since the names of the months don't change from one calendar year to the next.
Furthermore, unless you're doing some sort of locale changing to match different languages, there's really no need to use date() and mktime() at all just to get the names of the months. In other words, you could just do something like:
$months = [1=>'Jan', 'Feb', 'Mar', /* etc. */];
foreach($months as $idx => $month)
printf("<option value='%02d'>%s</option>\n", $idx, $month);
Likewise, I don't see why you're using date() and maketime() for the Day options either; you already know the ending day number for the month at that point, so when you're looping through all days from 1 until that ending day, why use mktime() and day() in order to get the exact same integer you started with? Seems rather silly.
As for the dependency part, though, you can't do it all once. PHP is executed on the server, the output is sent to the user, and the transaction is done. You'll need to generate a POST/GET request back to your server once the user has selected the year and month. To accomplish this, you could either have the user submit a form (which means they'll load a brand new page) or you could use AJAX (jQuery being the popular method) to submit the request behind-the-scenes and then populate the 'Day' dropdown accordingly.
However, note that if you're doing the Javascript approach, there's really no need to make a request back to your server at all - Javascript is perfectly capable of doing everything your PHP script above is doing without making any requests back to the server.