• 主页

# 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";

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);
}
}
}

...全文
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

2.1w+