gpt4 book ai didi

php excel转mysql问题

转载 作者:太空宇宙 更新时间:2023-11-03 11:13:48 25 4
gpt4 key购买 nike

我正在尝试为 mysql 构建一个 csv,我做的一切都正确,但是标题的第一行也一直在输入,我希望它从 csv 文件的第二行开始,

你能帮帮我吗:

    $row = 1;
if (($handle = fopen($file, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);

$userid = mysql_real_escape_string($Sid);
$amount = mysql_real_escape_string($data[0]);
$cardHolderName = mysql_real_escape_string($data[1]);
$cardHolderAddress = mysql_real_escape_string($data[2]);
$cardHolderZipcode = mysql_real_escape_string($data[3]);
$cardHolderCity = mysql_real_escape_string($data[4]);
$cardHolderState = mysql_real_escape_string($data[5]);
$cardHolderCountryCode = mysql_real_escape_string($data[6]);
$cardHolderPhone = mysql_real_escape_string($data[7]);
$cardHolderEmail = mysql_real_escape_string($data[8]);
$cardNumber = mysql_real_escape_string($data[9]);
$cardSecurityCode = mysql_real_escape_string($data[10]);
$cardExpireMonth = mysql_real_escape_string($data[11]);
$cardExpireYear = mysql_real_escape_string($data[12]);

$PurchaseDate = mysql_real_escape_string($data[13]);
$StoreId = mysql_real_escape_string($data[14]);

$ItemCode = mysql_real_escape_string($data[15]);
$ItemName = mysql_real_escape_string($data[16]);
$ItemQuantity = mysql_real_escape_string($data[17]);
$itemShippingType = mysql_real_escape_string($data[18]);

最佳答案

您需要获取第一行数据(标题行)并将其“丢弃”。您的代码示例在不跳过第一行的情况下开始处理。

if (($handle = fopen($file, "r")) !== FALSE) {
$data = fgetcsv($handle, 1000, ",");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
...

关于php excel转mysql问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6696797/

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