$kkk = custom_tuijian("2008-08-15",date("年月日"));
//回顯日期("Y-m-d");
//print_r($kkk);
function custom_tuijian($a,$b)
{
$sql = "從`中選擇`r`.*,`a`.`文章名`,`a`.`作者`
phpsir_record1` `r` 內連接`jieqi_article_article` `a`
on `r`.`bookid` = `a`.`articleid` where `r`.`rdate` = '$a' ";
; $res = mysql_query($sql);
$sql2 = "從`phpsir_record1` `r`內連接`jieqi_article_article` `a`
中選擇`r`.*,`a`.`文章名` ,`a`.`作者`
在`r`.`bookid` = `a`.`articleid` 上,其中`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);
}
回傳$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 $bookid=$kkk[$ii][2];
$ml=floor($bookid/1000);
$ml /www.kanshule.com/files/article/info/".$ml."/".$bookid.".htm'>".$kkk[ $ii][0]."";
}
以上就介紹了PHP多維資料庫 php資料庫應用之比較兩次時間的相減排序,包括了PHP多維資料庫方面的內容,希望對PHP教程有興趣的朋友有所幫助。