<?php
$row = 1;
$handle = fopen("ip-to-country.csv", "r");
while (($data = fgetcsv($handle, 1024, ",")) !== FALSE) {
$num = count($data);
//echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
echo "INSERT INTO iptoc(ip_from, ip_to, country_code2, country_code3, country_name) VALUES ";
echo "(" . "'" . addslashes($data[0]) . "','"
. addslashes($data[1]) . "','"
. addslashes($data[2]) . "','"
. addslashes($data[3]) . "','"
. addslashes($data[4]) . "'" .
");\n";
for ($c=0; $c < $num; $c++) {
//echo $data[$c] . "<br />\n";
}
}
fclose($handle);
?>
Title:
import db from csv file
Description:
<?php $row = 1; $handle = fopen("ip-to-country.csv", "r"); while (($data = fgetcsv($handle, 1024, ",")) !==...
...
Rating:
4