//connect to Database
mysql_select_db($database_csv, $csv);
if (isset($_POST['submit'])) {
if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
echo "<br><center><p>" . " ". $_FILES['filename']['name'] ." " . "</p></center>";
}
//Import uploaded file to Database
$handle = fopen($_FILES['filename']['tmp_name'], "r");
$firstRow = true;
$count = 0; //skip first line of the CSV file
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
if($count) //skip first line of the CSV file
{
$name=$data[0];
$description=$data[1];
$price=$data[2];
$shipping=$data[3];
$quantity=$data[4];
$import="INSERT into results (name,description,price,shipping,quantity) VALUES('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]')";
mysql_query($import) or die(mysql_error());
}
$count++;
}
fclose($handle);
?>
Uploading .CSV File using FileUpload in PHP/Mysql but the data in the csv all insert into one column amongs five columns, please read my code and help. Thanks in Advance..