sql与 foreach 问题

llj480028 2009-07-31 10:48:14
$XY["天水"] = "-270,150";
$XY["陇西"] = "-270,60";
$XY["嘉陵"] = "-270,-60";
$XY["云南"] = "-270,-180";
$XY["安定"] = "-210,240";
$XY["长安"] = "-180,150";
$XY["巴郡"] = "-210,-90";
$XY["建宁"] = "-210,-180";
$XY["交趾"] = "-180,-270";
$XY["陈仓"] = "-150,240";
$XY["汉中"] = "-150,90";
$XY["永安"] = "-150,-60";
$XY["晋阳"] = "-60,270";
$XY["襄阳"] = "-60,30";
$XY["武陵"] = "-90,-120";
$XY["江陵"] = "-30,-60";
$XY["长沙"] = "-30,-180";
$XY["上党"] = "60,270";
$XY["平原"] = "30,210";
$XY["陈留"] = "30,150";
$XY["汝南"] = "60,30";
$XY["新野"] = "30,-30";
$XY["江夏"] = "60,-90";
$XY["柴桑"] = "60,-150";
$XY["桂阳"] = "30,-210";
$XY["合肥"] = "120,-30";
$XY["庐陵"] = "120,-210";
$XY["北平"] = "180,210";
$XY["南皮"] = "180,150";
$XY["徐州"] = "180,90";
$XY["寿春"] = "150,30";
$XY["襄平"] = "270,270";
$XY["北海"] = "270,150";
$XY["下邳"] = "270,60";
$XY["吴郡"] = "270,-30";
$XY["会稽"] = "270,-90";

function add_famouse_city($xy){
foreach($xy as $cname=>$_xy){
$flag++;
list($x,$y) = explode(",",$_xy);
$query = "INSERT INTO t_city (cname,cx,cy,cb,cr,cppl,ctype,cctime) VALUES('$cname','$x','$y','".DEFAULT_FAMOUSCITY_BUILDING."','".DEFULT__FAMOUS_CITY_RESOURCE."','".DEFAULT_FAMOUSE_CITY_PEPOLE."','1',UNIX_TIMESTAMP())";
$cid = __insert($query);
if($cid){
$query = "INSERT INTO t_output (cid,cwood,cclay,ciron,cfood,cfoodulmt,cresulmt) VALUES($cid,".DEFAULT_FAMOUSE_CITY_WOOD.",".DEFAULT_FAMOUSE_CITY_CLAY.",".DEFAULT_FAMOUSE_CITY_IRON.",".DEFAULT_FAMOUSE_CITY_FOOD.",".DEFAULT_FAMOUSE_CITY_FOODULMT.",".DEFAULT_FAMOUSE_CITY_RESULMT.")";
__insert($query);

$query = "INSERT INTO t_city_force (cid) values('$cid')";
__insert($query);

$query="update t_city_force set fbb='1000' ,fgjbb='500',fjybb='300',fqb='800',fgjqb='400',fjyqb='200',fqib='300',fgjqib='150',fjyqib='100',fgnb='500',fxz='100',fcc='100',fsc='100' where cid='$cid'";
__update($query);

$query="update t_npc set cid='$cid',nlevel=23 where cid=0 and uid=0 and ngrade=3 or ngrade='2' order by rand() limit 1";
__update($query);

new_city_buff_by_building($cid);
}
}
}
为什么每次往数据库插入数据时,只能插入十几条?如果用foreach单独打印,会全部打出来的??
...全文
148 点赞 收藏 9
写回复
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
llj480028 2009-08-03
楼上的也许可以的!
回复
phpboy 2009-08-01
查看存入数据库的数据,找到断点数据,看是不是数据问题

数据存储过程,可添加判断

if(存储成功 == true)
{
//...
}
else
{
exit($query);
}
回复
llj480028 2009-07-31
是的!所以我感觉奇怪呢,不知道在哪出错了!
回复
blueforyou 2009-07-31
t_city里也只插入了10几条?
回复
YHL27 2009-07-31
顶!!
回复
C_learner_C 2009-07-31
飘过.
回复
fenyao 2009-07-31
代码的问题
回复
llj480028 2009-07-31
any one ?
回复
zl807108355 2009-07-31
哎,顶顶!
回复
发动态
发帖子
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
社区公告
暂无公告