PHP排序疑问
本帖最后由 u010801782 于 2013-07-30 23:32:15 编辑
<br>
<?php <br />
function switchWeek($num){<br>
switch ($num) {<br>
case 1:<br>
return '星期一';<br>
break;<br>
case 2:<br>
return '星期二';<br>
break;<br>
case 3:<br>
return '星期三';<br>
break;<br>
case 4:<br>
return '星期四';<br>
break;<br>
case 5:<br>
return '星期五';<br>
break;<br>
case 6:<br>
return '星期六';<br>
break;<br>
case 7:<br>
return '星期日';<br>
break;<br>
default:<br>
return '';<br>
break;<br>
}<br>
}<br>
$con = mysql_connect("localhost","root","") or die('连接失败:'.mysql_error());<br>
mysql_select_db("testt");<br>
mysql_query('set names utf8');<br>
$sql = 'select * from news ';<br>
$result = mysql_query($sql);<br>
$array = array();<br>
while($row = mysql_fetch_array($result,MYSQL_ASSOC)){<br>
$key = date('Y年m月d日',$row['sTime']).' '.switchWeek(date('N',$row['sTime']));<br>
$array[$key][]=$row;<br>
}<br>
mysql_free_result($result);<br>
//var_dump($array);<br>
?><br>
nbsp;html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><br>
<div class="clear">
</div>
Copy after login