下一篇 ? ? 上一篇

Figure 18-11: DateSelector

作者:semirock ???时间:2009-07-07??? 来源:http://444p.com??? 点击:30991 ???本文共1篇文章 字体:[ ]

Figure 18-11: DateSelector



Figure 18-11


/*
** create three selectors for date
*/
function DateSelector($name, $date)
{
$MonthName = array(1=>"January", "February", "March",
"April", "May", "June", "July", "August",
"September", "October", "November", "December");

if($date == "")
{
$date = time();
}

//Month
print("
$name . "Month\">\n");

for($currentMonth = 1;
$currentMonth <= 12;
$currentMonth++)
{
print("
if(date("m", $date) == $currentMonth)

本文来自 www.444p.com


{
print(" SELECTED");
}
print(">");
print($MonthName[$currentMonth]);
print("\n");
}
print("\n");

//Day
print("
$name . "Day\">\n");
for($currentDay = 1;
$currentDay <= 31;
$currentDay++)
{
print("
if(date("d", $date) == $currentDay)
{
echo " SELECTED";
}
echo ">$currentDay\n";
}
print("\n");

print("
$name . "Year\">\n");

$startYear = date("Y", $date);

for($currentYear = $startYear - 5; $currentYear <= $startYear+5;$currentYear++) www.444p.com
{
print("
if(date("Y", $date) == $currentYear)
{
print(" SELECTED");
}
print(">$currentYear\n");
}
print("\n");
}

print("\n");
print("\n");
print("Figure 18-11\n");
print("\n");

print("\n");

/*
** choose default date
*/
if(isset($SampleMonth))
{
//construct time
$UseDate = mktime(0, 0, 0,
$SampleMonth,
$SampleDay,
$SampleYear);
}
else
{
// use now
$UseDate = time();
}

print("
\n");

DateSelector("Sample", $UseDate);

php学习之家



print("\n");

print("
\n");

print("\n");
print("\n");
?>
责任编辑:semirock
发表评论
密码: (游客不需要密码)
记住我【Alt+S 或 Ctrl+Enter 快速提交】

搜索工具


《PHP函数》点击排行