2013-03-15 22 views

回答

0

它很容易。你需要谷歌阅读PHP中的文件,并用PHP写入数据库。

这里,我将带您起步:

$file_handle = fopen("cit.txt", "rb"); 

while (!feof($file_handle)) { 
    $line_of_text = fgets($file_handle); 
    // write your insert statement here, depending on your table structure. 
} 
1

或者试试:

$file = file_get_contents("city.txt"); 
$cities = explode("\n", $file); 

foreach ($cities as $city) { 

    $SQL = "INSERT INTO table_name (city) VALUES ('$city')"; 
    //now execute the SQL statement 

} 
相关问题