[ad_1]
can anyone help me why when i import the data the result is like that in the database i have provided the screenshot and the link . thanks
data in the db https://i.stack.imgur.com/TCmn1.png 
index.php
 <form enctype="multipart/form-data" method="post" action="import.php" role="form">
 <div class="form-group">
 <label for="exampleInputFile">File Upload</label>
 <input type="file" name="file" id="file" size="150">
 <p class="help-block">Only Excel/CSV File Import.</p>
 </div>
 <button type="submit" class="btn btn-default" name="Import" value="Import">Upload</button>
 </form>
import.php
<?php 
if(isset($_POST["Import"]))
 
 //First we need to make a connection with the database
 $host='localhost'; // Host Name.
 $db_user= 'root'; //User Name
 $db_password= '';
 $db= 'testdatabase'; // Database Name.
 $conn=mysql_connect($host,$db_user,$db_password) or die (mysql_error());
 mysql_select_db($db) or die (mysql_error());
 echo $filename=$_FILES["file"]["tmp_name"];
 if($_FILES["file"]["size"] > 0)
 
 $file = fopen($filename, "r");
 $count = 0;
 $sql_data = "SELECT * FROM person";
 echo $sql_data;
 while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
 
 //print_r($emapData);
 //exit();
 $count++;
 if($count > 1) 
 $sql = "INSERT into person(firstname , lastname) values ('$emapData[0]','$emapData[1]')";
 mysql_query($sql);
 
 
 fclose($file);
 echo 'CSV File has been successfully Imported';
 header('Location: index.php');
 
 else
 echo 'Invalid File:Please Upload CSV File';
?>
[ad_2]
لینک منبع