php数组应用之比较两个时间的相减排序_PHP教程
程序员文章站
2022-06-15 09:23:35
...
$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 $bookid=$kkk[$ii][2];
$ml=floor($bookid/1000);
echo "".$kkk[$ii][0]."";
}
//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 $bookid=$kkk[$ii][2];
$ml=floor($bookid/1000);
echo "".$kkk[$ii][0]."";
}
下一篇: SQL Server删除重复行的6个方法
推荐阅读
-
php比较两个绝对时间的大小_PHP教程
-
php比较多维数组中值的大小排序实现代码_PHP教程
-
php数组排序之ksort-对数组的元素键名进行升序排序_PHP教程
-
php数组函数序列之rsort() - 对数组的元素值进行降序排序_PHP教程
-
php数组函数排序之rsort() - 对数组的元素值进行降序排序_PHP教程
-
php数组应用之比较两个时间的相减排序
-
php数组应用之比较两个时间的相减排序_PHP教程
-
php数组之数组的元素值进行降序排序rsort()函数_PHP教程
-
php数组函数序列之array_intersect() 返回两个或多个数组的交集数组_PHP教程
-
PHP中比较两个时间的大小与日期的差值_PHP教程