$db = mysql_connect("localhost","root","000000");
mysql_select_db("demo",$db);
mysql_set_charset('utf8', $db);
}
/*虚假排行榜*/
function GetTheMonth($date){//获取指定日期所在月的第一天和最后一天
$firstday = date("Y-m-01",strtotime($date));
$lastday = date("Y-m-d",strtotime("$firstday +1 month -1 day"));
return array($firstday,$lastday);
}
function weblistpaihang($type){
$datetime = getthemonth(date('Y-m-d'));
$starttime = $datetime[0];//每月的第一天
$redtime = $datetime[1];//每月的最后一天
$day = date("d",time());
$name = "";
$point = "";
$nameArray = array("1","2","3","5","e", "输","入","和","参","指","明","了","主","法","f","g","今","天","是","h","i","j","k","l","m","n","o","个","好","日","子","v","w","x","y","z","A","B","C","D","阳","光","总","在","风","雨","后","K","L","O","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","这","个","世","离","了","谁","都","可","以","转","~","所","以","不","要","把","自","己","看","的","太","重","要","6","7","8","9","0","a","b","c","d","这","个","冬","季","依","旧","我","一","人","p","q","r","s","t","u","v","w","x","y","z","A","从","数","组","中","取","出","一","个","或","多","个","随","机","的","单","元","时","相","当","有","用","它","接","受","输","入","和","参","指","明","了","主","法");
switch ($type) {
case 'pub_Count':
$typenum=1;
break;
case 'rec_Count':
$typenum=2;
break;
case 'ref_Count':
$typenum=3;
break;
}
$sql = "select * from `bang` where type='".$typenum."' and createtime>'".$starttime."' and createtime<'".$redtime."' limit 10";
$result = mysql_query($sql);
$arr_Count = mysql_fetch_array($result);
if(count($arr_Count) < 10){
for($i=0;$i<10;$i++){
foreach (array_rand($nameArray,5) as $value) {
$name .= $nameArray[$value];
}
switch ($type) {
case 'pub_Count':
$point = rand(800,1200);
break;
case 'rec_Count':
$point = rand(500,800);
break;
case 'ref_Count':
$point = rand(100,300);
break;
}
$sql1 = "insert into `bang` (name,point,type,day,createtime) values ('".$name."','".$point."',".$typenum.",'".$day."','".date("Y-m-d H:i:s",time())."')";
$db1=mysql_query($sql1);
$arr_Count[$i]["name"] = $name;
$arr_Count[$i]["point"] = $point;
$name = "";
}
}else{
for($i=0;$i<10;$i++){
if($arr_Count[$i]["day"] != $day){
switch ($type) {
case 'pub_Count':
case 'rec_Count':
$rand = rand(100,200);
break;
case 'ref_Count':
$rand = rand(50,100);
break;
}
$arr_Count[$i]["point"] = $arr_Count[$i]["point"] + $rand;
$sql2 = "update `bang` set point='".$arr_Count[$i]["point"]."',day='".$day."' where id=".$arr_Count[$i]["id"]." and type=".$typenum;
$db=mysql_query($sql2);
}
}
}
return $arr_Count;
}
//echo "<pre>";
var_dump(weblistpaihang('rec_Count'));
//echo "</pre>";
$sqlxx = "select * from `bang` where type='3' and createtime>='2013-11-27 04:53:15' and createtime<'2013-11-27 04:53:41' limit 10";
$aa=mysql_query($sqlxx);
while($ror=mysql_fetch_assoc($aa)){
echo $ror['name'];
echo "~~~";
}
echo "<hr/>";
echo "<hr/>";
PHP排行榜也可以这么玩
最新推荐文章于 2024-11-14 15:22:28 发布