when i input this code it only uploads a single column into my database
<html>
<head>
<title>MySQL file upload example</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<form action="try2.php" method="post" enctype="multipart/form-data">
<input type="file" name="uploaded_file"><br>
<input type="submit" name="submit"value="Upload file">
</form>
<p>
<a href="list_files.php">See all files</a>
</p>
</body>
<?php
$con=mysqli_connect("localhost","root","","book");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if(isset($_POST['submit']))
{
$fname = $_FILES['uploaded_file']['name'];
$chk_ext = explode(".",$fname);
if(strtolower($chk_ext[1]) == "csv")
{
$filename = $_FILES['uploaded_file']['tmp_name'];
$handle = fopen($filename, "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$sql = "INSERT into data(name,Groups,phone_number) values('$data[0]','$data[1]','$data[2]')";
$result=mysqli_query($con,$sql) or die(mysql_error());
}
fclose($handle);
echo "Successfully Imported";
}
else
{
echo "Invalid File";
}
}
?>
</html>