当前位置:Gxlcms > PHP教程 > PHP排序疑点

PHP排序疑点

时间:2021-07-01 10:21:17 帮助过:17人阅读

PHP排序疑问
本帖最后由 u010801782 于 2013-07-30 23:32:15 编辑


function switchWeek($num){
switch ($num) {
case 1:
return '星期一';
break;
case 2:
return '星期二';
break;
case 3:
return '星期三';
break;
case 4:
return '星期四';
break;
case 5:
return '星期五';
break;
case 6:
return '星期六';
break;
case 7:
return '星期日';
break;
default:
return '';
break;
}
}
$con = mysql_connect("localhost","root","") or die('连接失败:'.mysql_error());
mysql_select_db("testt");
mysql_query('set names utf8');
$sql = 'select * from news ';
$result = mysql_query($sql);
$array = array();
while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
$key = date('Y年m月d日',$row['sTime']).' '.switchWeek(date('N',$row['sTime']));
$array[$key][]=$row;
}
mysql_free_result($result);
//var_dump($array);
?>

人气教程排行