Sorry for what is probably going to be a late reply. I'm waiting to pick someone up at the airport, and the plane was delayed, so I wanted to try my hand at answering your question.

First I had to figure out what method you used to pick those dates in the first place. It seems to be...

Today, Yesterday, then 1 day back for a total of 14 days (2 weeks)
Then going 1 week back for a total of 8 weeks (56 days)
Then I'm stumped how you came up with the jump from "9/14" to "8/31" to "8/1" unless the rule is go back 2 weeks then go back 30 days...
Is there a reason the next rule can't be: go 1 month back for a total of 11 months?

Here's a little piece of PHP code which will do just about exactly what you're looking for, with the rule modification I suggested. Perhaps it will do the trick? (And, since I'm no guru myself, I welcome comments on my suggestion). It basically works around "mktime" and "date". Both are very good functions to accomplish what you're trying to accomplish. Read up on those and you should be able to handle it.

<form name="foo">
<select name="bdate">
output_date_option ( mktime(0,0,0, date("m"), date("d"), date("Y")) , "Today" , "SELECTED" );
output_date_option ( mktime(0,0,0, date("m"), date("d")-1, date("Y")) , "Yesterday" );
for ($days = 2; $days <= 14; $days++) {
output_date_option ( mktime(0,0,0, date("m"), date("d")-$days, date("Y")) );
for ($weeks = 3; $weeks <= 7; $weeks++) {
output_date_option ( mktime(0,0,0, date("m"), date("d")-($weeks*7), date("Y")) );
for ($months = 2; $months <= 11; $months++) {
output_date_option ( mktime(0,0,0, date("m")-$months, date("d"), date("Y")) );

function output_date_option($current_date, $date_string = "", $xparams = "") {
if (!isset($date_string) or $date_string == "") {
$date_string = date ( "D m/d" , $current_date );
echo ( '<OPTION VALUE="'.date ( "m/d/Y" , $current_date ).'" '.$xparams.'>'.$date_string );

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to