$link=mysqli_connect("localhost","root","dengli","yilonggu");
$link->query("delete from message");
function suijishijian()
{
$month=array('0','01','02','03','04','05','06','07','08','09','10','11','12');
$days=array('0','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31');
$hour=array('0','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','00');
$fz=array("","00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59");
$day=array(
"01"=>"31",
"02"=>"28",
"03"=>"31",
"04"=>"30",
"05"=>"31",
"06"=>"30",
"07"=>"31",
"08"=>"31",
"09"=>"30",
"10"=>"31",
"11"=>"30",
"12"=>"31");
$y=rand(2010,2013);
$m=$month[rand(1,12)];
$d=$days[rand(1,$day["$m"])];
$h=$hour[rand(1,24)];
$mm=$fz[rand(1,60)];
$s=$fz[rand(1,60)];
return "$y-$m-$d $h:$mm:$s\n";
}
function floadNumber($min,$max)
{
return $min + mt_rand() / mt_getrandmax() * ($max - $min);
}
function shengfen($jd,$wd)
{
$url="http://api.map.baidu.com/geocoder?location={$wd},{$jd}&output=json";
$json=json_decode(file_get_contents($url),TRUE);
return $json['result']['addressComponent']['province'];
}
for($i=1;$i<10000;$i++)
{
$zid=rand(1,99999);
$time=suijishijian();
$jingdu=floadNumber(100,120);
$weidu=floadNumber(30,40);
$province=shengfen($jingdu,$weidu);
$lid=rand(1,13);
$type=rand(0,3);
$tag=rand(1,4);
$sbh=md5(time());
$sql="insert into `tongji` (zid,time,jingdu,weidu,province,lid,type,tag,sbh) VALUES ('{$zid}','{$time}','{$jingdu}','{$weidu}','{$province}','{$lid}','{$type}','{$tag}','{$sbh}')";
$link->query($sql);
echo $sql."\n";
}
$link->close();
?>
这个数据表的结构,截图如下
标签:PHP