I am trying to insert csv file data into mysql but i am not able to put duplication check on claim_refno,claim_parcelno please help me to how can i put duplication check on these two fields on insertion...please help
Here is my php code:
<?php
session_start();
include"connection.php";
if (!isset($_SESSION['adm_id'])){
header("location: index.php");
}
else{
include "connection.php"; //Connect to Database
//Upload File
if (isset($_POST['submit'])) {
if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
$note= "<br/><span style='color:red;'>'" . "File ". $_FILES['filename']['name'] ."</span> uploaded successfully." ."";
}
//Import uploaded file to Database
//$firstRow = true;
$j=0;
$handle = fopen($_FILES['filename']['tmp_name'], "r");
$firstRow = true;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($firstRow) { $firstRow = false; }
else{
$import="insert into tbl_claimdetail(claim_dateclaim,claim_clientname ,claim_account,claim_contract,claim_parcelno ,claim_refno,claim_datecollected,claim_coladdress ,claim_colpostcode,claim_counsineaddres,claim_conpostcode,claim_retailvalue,claim_claimvalue,claim_protitle,claim_reason ,claim_type,claim_repparcelno) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]','$data[10]','$data[11]','$data[12]','$data[13]','$data[14]','$data[15]','$data[16]')";
mysql_query($import) or die(mysql_error());
$j++;
$msg = '<br/>Total <span style="color:red;">'.$j.'</span> Record has been added.';
}
}
fclose($handle);
}else {
}
include"header.php";
include"leftmenu.php";
include"html/upload.html";
include"footer.php";
}
?>