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>";
}
//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>";
}
相关推荐
Tips 2020-04-30
Jasmineyaoyao 2020-04-15
dbhllnr 2020-02-18
清溪算法 2020-02-15
范范 2019-12-03
duanlove技术路途 2019-11-09
seekerhit 2019-11-04
youandme 2019-07-01
基尔霍夫的猫 2019-07-01
基尔霍夫的猫 2019-07-01
算法改变人生 2019-06-28
根据指针的不同使用方式,链表又可以分为单链表、双向链表和循环链表。特别的,对于双向链表,给定一个结点,要找出其前驱结点时,时间复杂度为 O,单链表则仍为 O。这也是双向链表在实际开发中经常使用的原因。
鱼天翱 2019-06-28
什么是数组数组是一种线性表数据结构,它用一组连续的内存空间来存储一组具有相同类型的数据。典型的线性表有数组、链表、队列和栈。直接将第 k 位的数据搬移到数组元素最后,然后把新的元素直接放在第 k 位。
AreayGK 2019-06-28
RememberMePlease 2015-09-06
qizongshuai 2016-05-27
学习编程 2018-05-09
MATLAB 2018-03-04