I am inserting the csv file into the database but it not inserting in proper way,the coloums are merged into each other,im not getting where im doing mistake .please help me in that my code`Inline

<?php 

//database connection details
$connect = mysql_connect('localhost','root','123456');

if (!$connect) {
 die('Could not connect to MySQL: ' . mysql_error());
 }

//your database name
$cid =mysql_select_db('ingram',$connect);



// Name of your CSV file
$csv_file = "857869.csv";
$count = 0;
if (($getfile = fopen($csv_file, "r")) !== FALSE) { 
        $data = fgetcsv($getfile, 1000, ",");
        while (($data = fgetcsv($getfile, 1000, ",")) !== FALSE) {
        $count++;
        if($count > 10000) {
            die;
        }
            print_r($data);
         $num = count($data); 
         for ($c=0; $c < $num; $c++) {
         $result = $data; 
             $str = implode(",", $result); 
             $fileop = explode(",", $str);
        $GRUPPE1=$fileop[0];
        $GRUPPE2=$fileop[1];
        $GRUPPE3=$fileop[2];
        $HERSTELLER=$fileop[3];
        $ARTIKEL_NR=$fileop[4];
        $ARTIKEL1=$fileop[5];
        $ARTIKEL2=$fileop[6];
        $FVERSION=$fileop[7];
        $FSYSTEM=$fileop[8];
        $FSPRACHE=$fileop[9];
        $FFORMAT=$fileop[10];
        $FBUS=$fileop[11];
        $FGARANTIE=$fileop[12];
        $EVP=$fileop[13];
        $EK=$fileop[14];
        $AKTIONPR=$fileop[15];
        $AKTBIS=$fileop[16];
        $AKTION=$fileop[17];
        $VERFUEGBAR=$fileop[18];
        $VMENGE=$fileop[19];
        $VDATUM=$fileop[20];
        $VETA=$fileop[21];
        $NACHFOLGER=$fileop[22];
        $DATENBLATT=$fileop[23];
        $BILD=$fileop[24];
        $ERFDAT=$fileop[25];
        $EANCODE=$fileop[26];
        $UPCCODE=$fileop[27];
        $HOEHE=$fileop[28];
        $BREITE=$fileop[29];
        $LAENGE=$fileop[30];
        $GEWICHT=$fileop[31];
        $RANG=$fileop[32];
        $Stck_Kart=$fileop[33];
        $Stck_Pal=$fileop[34];
        $Storno=$fileop[35];
        $EClass=$fileop[36];
        $UNSPSC=$fileop[37];
        $INTRASTAT=$fileop[38];
        $CatalogID=$fileop[39];

// SQL Query to insert data into DataBase

$sql="INSERT INTO `product`(`id`, `GRUPPE1`, `GRUPPE2`, `GRUPPE3`, `HERSTELLER`, `ARTIKEL_NR`, `ARTIKEL1`, `ARTIKEL2`, `FVERSION`, `FSYSTEM`, `FSPRACHE`, `FFORMAT`, `FBUS`, `FGARANTIE`, `EVP`, `EK`, `AKTIONPR`, `AKTBIS`, `AKTION`, `VERFUEGBAR`, `VMENGE`, `VDATUM`, `VETA`, `NACHFOLGER`, `DATENBLATT`, `BILD`, `ERFDAT`, `EANCODE`, `UPCCODE`, `HOEHE`, `BREITE`, `LAENGE`, `GEWICHT`, `RANG`, `Stck_Kart`, `Stck_Pal`, `Storno`, `EClass`, `UNSPSC`, `INTRASTAT`, `CatalogID`) VALUES ('','$GRUPPE1','$GRUPPE2','$GRUPPE3','$HERSTELLER','$ARTIKEL1','$ARTIKEL2','$FVERSION','$FVERSION','$FSYSTEM','$FSPRACHE','$FFORMAT','$FBUS','$FGARANTIE','$EVP','$EK','$AKTIONPR','$AKTBIS','$AKTION','$VERFUEGBAR','$VMENGE','$VDATUM','$VETA','$NACHFOLGER','$DATENBLATT','$BILD','$ERFDAT','$EANCODE','$UPCCODE','$HOEHE','$BREITE','$LAENGE','$GEWICHT','$RANG','$Stck_Kart','$Stck_Pal','$Storno','$EClass','$UNSPSC','$INTRASTAT','$CatalogID')";
echo $sql;die();
$s=mysql_query($sql, $connect ); 
     }
   } 
  }

echo "File data successfully imported to database!!"; 
mysql_close($connect); 
?>
?>

Code Example Here`

This table is useful to convert the file in CVS format.

thanks rch1231 ,i visited that link but still facing same issue with the inserting records in table according to csv format .

batoo1 yeah but the format is the issue for me

done with that issue was exploding it and not using "\t" the improve secticon of code is`

Inline Code Example Here

if (($getfile = fopen($csv_file, "r")) !== FALSE) { 
        $data = fgetcsv($getfile, 1000,"\t");
        while (($data = fgetcsv($getfile, 1000, "\t")) !== FALSE) {
        $count++;
        if($count > 10000) {
            die;
        }
            print_r($data);
         $num = count($data); 
         for ($c=0; $c < $num; $c++) {
         $result = $data;

        $str = implode("",$result); 

        $fileop = implode(" ",$fileop1);
         $fileop=$result;
        $GRUPPE1=$fileop[0];
        $GRUPPE2=$fileop[1];
        $GRUPPE3=$fileop[2];
        $HERSTELLER=$fileop[3];

        }

`

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.