Tak tylko w moim przypadku data[0] - data[6] to kolumny czyli plik csv wyglada tak id imie nazwisko data... i te kolumny sa brane wpisywane do bazy kazdy wiersz to 6 imputow.T co napisales wiswietli mi pierwsza dana ostatniego wiersza tak ?
<?php
$x = 0;
if ($file = fopen("invoices.csv")) { foreach($file as $l) {
$data[$x]["id"] = time() + $x; $data[$x]["clientid"] = trim($record[0
]); $data[$x]["invoiceid"] = trim($record[2
]); $data[$x]["nettotal"] = trim($record[4
]); $data[$x]["taxtotal"] = trim($record[5
]); $data[$x++]["grosstotal"] = trim($record[6
]); }
}
$message = "";
foreach($data as $d) {
if ($d["clientid"] != "" && $d["invoiceid"] != "") {
mysql_query("delete from items where customer_id = '" . $d["clientid"] . "' and invoice_id = '" . $d["invoiceid"] . "'"); mysql_query("insert into items (id, customer_id, customer_name, invoice_id, invoice_date, net, tax, price) values (" . $d["id"] . ", '" . $d["clientid"] . "', '" . $d["clientname"] . "', '" . $d["invoiceid"] . "', '" . $d["invoicedate"] . "', " . $d["nettotal"] . ", " . $d["taxtotal"] . ", " . $d["grosstotal"] . ")") or
die(mysql_error() . "<br/>insert into items (id, customer_id, customer_name, invoice_id, invoice_date, net, tax, price) values (" . time() . ", '" . $d["clientid"] . "', '" . $d["clientname"] . "', '" . $d["invoiceid"] . "', '" . $d["invoicedate"] . "', " . $d["nettotal"] . ", " . $d["taxtotal"] . ", " . $d["grosstotal"] . ")"); $message .= "Client ID: " . $d["clientid"] . "\nInvoice ID: " . $d["invoiceid"] . "\n\n";
}
}
?>
Tylko cos mi nie chce mi wpisac do bazy....