Remove Duplicate data Import CSV file in MySQL db using PHP

Description

How to Remove Duplicate data while Import CSV file in MySQL db using PHP, Duplicate data not upload in mysql CSV file, Update mysql database and Remove Duplicate data while upload CSV file php, upload CSV file data using mysql php Automatic import and Remove Duplicate data of CSV files to Mysql Using PHP, Skipping Duplicates data on Insert data to mysql using php step by step upload and save Mysql Data using upload CSV file

Remove Duplicate data and Import CSV file in MySQL db using PHP

 

<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">

  Choose your file: <br />

  <input name="csv" type="file" id="csv" />

  <input type="submit" name="Submit" value="Submit" />

 

</form>

Start php Code for upload and Remove Duplicate data Import CSV file in MySQL db using PHP

<?php 

ob_start();

 error_reporting(0);

//include_once("header.php");

include_once("confidbfile.php");

//connect to the database

//$connect = mysql_connect("localhost","root","");

//mysql_select_db("shriramcsv",$connect); //select the table

//

if ($_FILES[csv][size] > 0) {

    //get the csv file

    $file = $_FILES[csv][tmp_name];

    $handle = fopen($file,"r");

    //loop through the csv file and insert into database

    do {

        if ($data[0]) { 

 

$fname = $data[0];

//echo $fname;

      // $lname = $data[2];

 //echo "select count(*) as adminid from manageadminbatchlist where adminid='" . $fname . "' ";

$sql = "select count(*) as adminid from manageadminbatchlist where adminid='" . $fname . "' ";

       $retrieve_data = mysql_query($sql);

       $row = mysql_fetch_array($retrieve_data);

       $count = $row['adminid'];

 //echo  $count;

if($count == 0){  // count if bracker start

// mysql_query("INSERT INTO addstudent (sn, adminno, Image, mobile, dob, doa, studentname, fathername, qualification, city, course, batch, address, bag, idcard, book1, book2, book3, book4, book5, book6, sex, catagery )   VALUES

 mysql_query("INSERT INTO manageadminbatchlist (adminid, batchcode ) VALUES

                (

                    '".addslashes($data[0])."',

'".addslashes($data[1])."'

                )

            ");

} // count if bracker stop

        }

    } while ($data = fgetcsv($handle,1000,",","'"));

    //

    //redirect

   // header('Location: import.php?success=1'); die;

}

?>