As the title says. I have a website with table showing ranks of poker tournaments, I have created a db where I uploaded a csv file with the last tournamet. It´s works great. But i can´t figure out have to update point and rank, when uploading a new csv. If player one has 6 points and the in the new cvs file the same player has 4 points, i want it to add the new 4 point to the 6 from the last tournament. And then update the rank position. Thanks in advance. Code: <?php // include mysql database configuration file include_once 'db.php'; if (isset($_POST['submit'])) { // Allowed mime types $fileMimes = array( 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ); // Validate whether selected file is a CSV file if (!empty($_FILES['file']['name']) && in_array($_FILES['file']['type'], $fileMimes)) { // Open uploaded CSV file with read-only mode $csvFile = fopen($_FILES['file']['tmp_name'], 'r'); // Skip the first line fgetcsv($csvFile); // Parse data from CSV file line by line // Parse data from CSV file line by line while (($getData = fgetcsv($csvFile, 10000, ",")) !== FALSE) { // Get row data $rank = $getData[0]; $name = $getData[1]; $points = $getData[2]; // If user already exists in the database with the same name $query = "SELECT id FROM ranking WHERE name = '" . $getData[1] . "'"; $check = mysqli_query($conn, $query); if ($check->num_rows > 2) { mysqli_query($conn, "UPDATE ranking SET rank = '" . $rank . "', name = '" . $name . "', points'" . $points . "'"); } else { mysqli_query($conn, "INSERT INTO ranking (rank, name, points) VALUES ('" . $rank . "', '" . $name . "', '" . $points . "')"); } } // Close opened CSV file fclose($csvFile); header("Location: ../leaderboard.php"); } else { echo "Please select valid file"; } }