Home > Backend Development > PHP Tutorial > php循环插入数据库某个id范围值

php循环插入数据库某个id范围值

WBOY
Release: 2016-06-23 13:27:13
Original
952 people have browsed it

$uid= 比如是100000111到100500000for($i=0;$i<count($uid);$i++){$sql="insert intousers (uid,fromid) values($uid,0) ";}
Copy after login

怎么循环把这两个id内的id循环插入到表里面呢?


回复讨论(解决方案)

你这个方法不行吗?

你这个方法不行吗?


i是从0开始的,用户id不是从0开始的,不知道怎么来实现了
$sql="insert into users (uid,fromid) values($i,0) ";

加个初值就是了

加个初值就是了


for($i=0;$i<count($uidxx);$i++){$sql="insert into user_relation (uid,formId,status,addtime) values('".$i."',0,0,'')";mysql_query($sql);echo $sql;$i++;}
Copy after login

怎么只执行了一次呢

呃,弄好了,那个addtime是timestamp这个类型的,但是插入数据库看到的是0000-00-00 00:00:00呢

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template