gpt4 book ai didi

php - 插入csv文件多行多数据

转载 作者:行者123 更新时间:2023-11-29 15:38:58 26 4
gpt4 key购买 nike

4202,4203
4204,4205,4207
4246,4247,4248,4249,4250
4815,4816,4817,4818,4819,4820
4824,4825,4826,4827,4828,4847,4848,4849
5143,5145,5146,5147,5148,5149

this is my csv file

逐行插入数据

insert into praking_location (Parking_meter_id) values (" csv file data")

我想插入 500 多个数据。

$open = fopen('meterid.csv','r'); 
while (!feof($open)) {

$getTextLine = fgets($open);
$explodeLine = explode(",",$getTextLine);

list($meter) = $explodeLine;

$qry = "insert into praking_location (Parking_meter_id)
values('".$meter."')";
mysqli_query($conn,$qry);
}
echo 'data inserted';

最佳答案

$open = fopen('meterid.csv','r'); 
while (!feof($open)) {

$getTextLine = fgets($open);
$explodeLine = explode(",",$getTextLine);

foreach($explodeLine as $meter) {
$qry = "insert into praking_location (Parking_meter_id)
values('".$meter."')";
mysqli_query($conn,$qry);
}
}
echo 'data inserted';

关于php - 插入csv文件多行多数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57885368/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com