I already have a php file that catches data from an uploaded CSV file to MySQL but the problem is, every time I upload the csv file, it duplicates the data into the MySQL
What i really want is, if I uploaded the first csv file, and edit some data on the same file, it will UPDATE the MySQL data. But if there's a new entry it will ofcourse add..
<?php
$conn = mysql_connect("localhost", "root", "") or die (mysql_error());
mysql_select_db("sbhs",$conn);
if(isset($_POST['submit']))
{
$file = $_FILES['file']['tmp_name'];
$handle = fopen($file,"r");
while(($fileop = fgetcsv($handle,1000, ",")) !== false )
{
$firstname = $fileop[0];
$lastname = $fileop[1];
$email = $fileop[2];
$sql = mysql_query("INSERT INTO test (first_name,last_name,email) VALUES ('$firstname','$lastname','$email') ");
}
if($sql)
echo "Uploaded Successfully";
}
?>
<html>
<head>
</head>
<body>
<div id="mainWrapper">
<form method="post" action="test.php" enctype="multipart/form-data">
<input type="file" name="file"/>
<br/>
<input type="submit" name="submit" value="submit"/>
</form>
</div>
</body>
</html>
PLEASE I REALLY NEED THIS
By the way, anyone who has a GRADING SYSTEM using PHP?
thanks