Forum Moderators: coopster
$data = fopen('file.txt', 'r');
while ($row = (fgetcsv($rssc , 1000, "¦"))) {
$sql = "insert into table values ('".
implode("','", $row) ."')";
mysql_query($sql);
}
Is the second file I am having problems with. It is a .xls file with values separated by tabs. I have not found a way to make the above code work for tab separated values so I tried this one:
$data = file ('file.xls');
for($i=0; $i<sizeof($data); $i++) {
$line = trim($data[$i]);
$arr = explode("\t", $line);
$sql = "insert into table values ('".
implode("','", $arr) ."')";
mysql_query($sql);
}
this code works partially. It loads some values to the detabase but not all of them. Somehow it skips some records and I cannot figure out why. Can anyone spot the problem?
$data = file ('file.xls');
$size = sizeof($data);
for($i=0; $i < $size; $i++) {
...
}
There's a discussion about this over here [webmasterworld.com]. message #4 & #15