
Originally Posted by
sid egg
As to #4, what does that mean :P? Some examples please?
I suppose it's easier to post the whole thing than to try and explain it 
PHP Code:
class whatever()
{
/*---- SNIP ------*/
function month_list()
{
$months = array(
"January" => "1",
"February" => "2",
"March" => "3",
"April" => "4",
"May" => "5",
"June" => "6",
"July" => "7",
"August" => "8",
"September" => "9",
"October" => "10",
"November" => "11",
"December" => "12",
);
return $months;
}
function day_list()
{
$days = array();
for ($m = 1; $m <= 31; $m++)
{
$days[] = $m;
}
return $days;
}
function year_list($back, $ahead)
{
$this_year = date("Y");
$years = array();
for ($y = $this_year - $back; $y <= ($this_year + $ahead); $y++)
{
$years[] = $y;
}
return $years;
}
function date_dropdowns($select_field_name="", $select_time="", $use_days=1, $years_back=2, $years_ahead=1)
{
if ($select_time != "")
{
$sel_month = date("F", $select_time);
$sel_date = date("d", $select_time);
$sel_year = date("Y", $select_time);
}
$this->datelist = "<select name='";
if ($select_field_name !="")
{
$this->datelist .= $select_field_name . "_";
}
$this->datelist .= "month'>";
foreach ($this->month_list() as $k => $v)
{
$this->datelist .= "<option value='" . $v . "'";
if ($sel_month == $k)
{
$this->datelist .= " selected='selected'";
}
$this->datelist .= ">" . $k . "</option>";
}
$this->datelist .= "</select> <select name='";
if ($use_days == 1)
{
if ($select_field_name !="")
{
$this->datelist .= $select_field_name . "_";
}
$this->datelist .= "day'>";
foreach ($this->day_list() as $k)
{
$this->datelist .= "<option value='";
if ($k < 10)
{
$this->datelist .= "0";
}
$this->datelist .= $k . "'";
if ($sel_date == $k)
{
$this->datelist .= " selected='selected'";
}
$this->datelist .= ">" . $k . "</option>";
}
$this->datelist .= "</select> <select name='";
}
if ($select_field_name !="")
{
$this->datelist .= $select_field_name . "_";
}
$this->datelist .= "year'>";
foreach ($this->year_list($years_back, $years_ahead) as $k)
{
$this->datelist .= "<option value='" . $k . "'";
if ($sel_year == $k)
{
$this->datelist .= " selected='selected'";
}
$this->datelist .= ">" . $k . "</option>";
}
$this->datelist .= "</select>";
return $this->datelist;
}
}
Bookmarks