Jump to content

Export xls or csv file into mysql database


Nandini

Recommended Posts

Hi all

 

I want to export a xls or csv file (which is having number of user details) into mysql database table. And i want to validate that xls file. That means i don't want to accept duplicate entries etc. How can i do this.

 

Can anyone send me scripts or url's.

 

Thanq

I  am trying to get data from xls file. But i am getting some garbage value. See this output.

 

nࡱ��nnࡱ�nࡱࡱࡱࡱࡱ�nࡱ�nࡱࡱ�nࡱࡱࡱ�nࡱ�nࡱ�nࡱࡱࡱ�nࡱ�

 

The above output i am getting when i execute the following program.

 

<?

// open the text file

$fd = fopen ("test.csv", "r");

// initialize a loop to go through each line of the file

while (!feof ($fd)) {

$buffer = fgetcsv($fd, 4096); // declare an array to hold all of the contents of each

//row, indexed

echo "n";

// this for loop to traverse thru the data cols

// when this is re-created with MySQL use the mysql_num_fileds() function to get

// this number

for ($i = 0; $i < 5; ++$i){

if ($buffer[$i] == ""){

$buffer[$i] = " ";

}

// print 's with each index

echo "$buffer[$i]n";

}

echo "n";

}

fclose ($fd);

?>

 

Please help me out

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.