<?php
//创建数据库执行一次即可! $i=0; while($i<=99){ $sql="CREATE TABLE `code_".$i."` ( `full_code` char(10) NOT NULL, `create_time` int(10) unsigned NOT NULL, PRIMARY KEY (`full_code`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; $res = mysql_query($sql); $i++; }
$conn = mysql_connect('localhost','root',''); mysql_select_db('ab');
function insert($id){ $code_id = $id % 100; $db_name = 'code_'.$code_id; $sql = 'INSERT INTO '.$db_name.' VALUE ('.$code_id.rand(1,9).','.time().')'; $res = mysql_query($sql); if($res){ echo $code_id; }else{ echo $sql." "; echo 'fail:'.$id; } } for($i=0;$i<200;$i++){ $id = rand(1,10000); insert($id); }