程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php數組應用之比較兩個時間的相減排序

php數組應用之比較兩個時間的相減排序

編輯:關於PHP編程

$kkk = custom_tuijian("2008-08-15",date("Y-m-d"));
//echo date("Y-m-d");
//print_r($kkk);

function custom_tuijian($a,$b)
{
$sql = "select `r`.*,`a`.`articlename`,`a`.`author`
from `phpsir_record1` `r` inner join `jieqi_article_article` `a`
on `r`.`bookid` = `a`.`articleid` where `r`.`rdate` = '$a' ";
$res = mysql_query($sql);
$sql2 = "select `r`.*,`a`.`articlename`,`a`.`author`
from `phpsir_record1` `r` inner join `jieqi_article_article` `a`
on `r`.`bookid` = `a`.`articleid` where `r`.`rdate` = '$b' ";
$res2 = mysql_query($sql2);
while($row = mysql_fetch_assoc($res))
{
$row2 = mysql_fetch_assoc($res2);
$calnum = calnum($row,$row2);
$a_a[$row['bookid']] = $calnum;
$x[$row['bookid']] = array($row["articlename"],$row["author"],$row["bookid"]);
}
arsort($a_a);
foreach($a_a as $k=>$v)
{

$kk[] = array($x[$k][0],$x[$k][1],$x[$k][2],$v);
}

return $kk;
}
function calnum($r1,$r2)
{
// 公式 點擊/100+推薦*2+收藏+鮮花*10+月票*10
return ($r2['clicknum'] - $r1['clicknum']) / 100 + ($r2['shoucangnum'] - $r1['shoucangnum'])
+ ($r2['xianhuanum'] - $r1['xianhuanum']) * 10 + ($r2['yuepiaonum'] - $r1['yuepiaonum']) * 10 ;
}
//數據調用方法
for($ii=0; $ii<100; $ii++){
    $bookid=$kkk[$ii][2];
    $ml=floor($bookid/1000);
    echo "<a href='http://www.kanshule.com/files/article/info/".$ml."/".$bookid.".htm'>".$kkk[$ii][0]."</a>";
    }

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved