
October 21st, 2012, 01:55 PM
|
|
|
|
Import CSV file but gives ""
Hey guys i have a CSV uploader but i don't know what format i should save the xls to CSV ..cause i tryed comma delimited..
when i import to mysql i get "name" ...
what CSV format should i use?
uploader
PHP Code:
if ($_FILES[csv][size] > 0) {
//get the csv file
$file = $_FILES[csv][tmp_name];
$handle = fopen($file,"r");
//loop through the csv file and insert into database
do {
if ($data[0]) {
mysql_query("INSERT INTO $Year (Ecole,N_Fiche,Nom,Prenom,Code_P,Foyer,Secondaire,Annee,Sortie) VALUES
(
'263',
'".addslashes($data[0])."',
'".addslashes($data[1])."',
'".addslashes($data[2])."',
'".addslashes($data[5])."',
'".addslashes($data[6])."',
'".addslashes($data[4])."',
'$Year',
'".addslashes($data[7])."'
)
");
}
} while ($data = fgetcsv($handle,1000,",","'"));
//
//redirect
echo "<meta http-equiv=Refresh content=1;url=Admin.php?success=1>";die;
}
|