這個不能直接輸出,要利用date這個函數來實現.然后生成一個數組,把下標賦給星期 再利用switch循環.
<?php
$today= "00:00:00 01-30-2003 ";
$w=date( "w ",mktime($today));
$week=array(
"0 "=> "星期日 ",
"1 "=> "星期一 ",
"2 "=> "星期二 ",
"3 "=> "星期三 ",
"4 "=> "星期四 ",
"5 "=> "星期五 ",
"6 "=> "星期六 "
);
switch ($week[$w]){
case 0:
echo ''.$week[$w];
$sql=$empire->query("select * from {$dbtbpre}ecms_news where w='".$week[$w]."' order by newstime limit 10");
while($r=$empire->fetch($sql))
{
echo $r[title];
}
break;
case 1:
echo ''.$week[$w];
$sql=$empire->query("select * from {$dbtbpre}ecms_news where w='".$week[$w]."' order by newstime limit 10");
while($r=$empire->fetch($sql))
{
echo $r[title];
}
break;
case 2:
echo ''.$week[$w];
$sql=$empire->query("select * from {$dbtbpre}ecms_news where w='".$week[$w]."' order by newstime limit 10");
while($r=$empire->fetch($sql))
{
echo $r[title];
}
break;
case 3:
echo ''.$week[$w];
$sql=$empire->query("select * from {$dbtbpre}ecms_news where w='".$week[$w]."' order by newstime limit 10");
while($r=$empire->fetch($sql))
{
echo $r[title];
}
break;
case 4:
echo ''.$week[$w];
$sql=$empire->query("select * from {$dbtbpre}ecms_news where w='".$week[$w]."' order by newstime limit 10");
while($r=$empire->fetch($sql))
{
echo $r[title];
}
break;
case 5:
echo ''.$week[$w];
$sql=$empire->query("select * from {$dbtbpre}ecms_news where w='".$week[$w]."' order by newstime limit 10");
while($r=$empire->fetch($sql))
{
echo $r[title];
}
break;
case 6:
echo ''.$week[$w];
$sql=$empire->query("select * from {$dbtbpre}ecms_news where w='".$week[$w]."' order by newstime limit 10");
while($r=$empire->fetch($sql))
{
echo $r[title];
}
break;
}
?>
補充:有點小錯誤 把switch ($week[$w]) 改成 switch ($w)w是星期字段,news是調用的數據表