I'm trying to upload some files to MySQL as a project, but the problem is that if I select the file 2 or more times it comes back and uploads them.
The idea is to make when you try to upload the file read the rows and say that X number of cells have already been uploaded, or if the entire file has already gone up then show it.
I am trying to do it for MYSQL, but I do not know if it is the most optimal way.
IF NOT EXISTS( SELECT carnet FROM Tabla_Carnet (NOLOCK) WHERE carnet = XXXXX )
BEGIN
INSERT INTO Tabla_Carnet( carnet, fecha)
VALUES( carnet, GETDATE() )
END
Here is what I'm inserting, therefore, are the same data from the XLSX file
$sql = 'INSERT INTO Tabla_Carnet ( fecha,
carnet,
hora,
nombre,
apellido,
sexo,
edad,
ocupacion,
estudios,
discapacidad)
VALUES( "'.$data.'",
"'.$hora.'",
"'.$data[2].'",
"'.$data[3].'",
"'.$data[6].'",
"'.$data[7].'",
"'.$data[8].'",
"'.$data[9].'",
"'.$data[10].'",
"'.$data[12].'")';
$contador++;
Where the $ sql is executed
if ($data[7] != '')
{
mysql_query($sql) or die(mysql_error());
if (!$sql)
{
echo '<div>¡Oh, detectamos un problema!
<br>¡Por favor vuelva a intentarlo!</div>';
exit;
}
}