Php inserts 1000 data records into mysql. how can this problem be solved ??? For ($ I = 1; $ I & lt; = 1000; $ I ++) {& nbsp; $ id = & quot; 100 & quot; & nbsp; $ username = & quot; xm & quot; & nbsp; $ SQL = & quot; I php inserts 1000 pieces of data into mysql. how can I write ???
For ($ I = 1; $ I <= 1000; $ I ++)
{
USD id = "100 ";
$ Username = "xm ";
$ SQL = "insert into tb_user (id, username) values ('$ ID',' $ username ')";
Mysql_query ($ SQL );
}
I didn't set id and username as the primary key,
But insert a piece of data. what is the problem? Thank you!
------ Solution --------------------
Do not operate databases frequently. Suggestions
PHP code
For ($ I = 1; $ I <= 1000; $ I ++) {$ id = '000000'; $ username = 'xm '; $ SQL [] = '('. $ id. ',"'. $ username. '")';} mysql_query ('Insert into tb_user (id, username) values '. implode (',', $ SQL ));