这个不能直接输出,要利用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是调用的数据表

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。