MYSQL - Insert data from a text file into the table - PHPMyAdmin

Associate
Joined
19 Mar 2005
Posts
569
I currently have a problem, I have a countries table and want to insert every country of the world.

The table is set up as follows:

PHP:
CREATE  TABLE  `countries` ( `countryID` INT( 255  )  NOT  NULL  AUTO_INCREMENT ,
 `countryName` VARCHAR( 250  )  NOT  NULL ,
 PRIMARY  KEY (  `countryID`  ) ) TYPE  =  MYISAM ;

I want to read in the file below and input all the country names and each have an auto_incremented id. How would I go about formatting the text file below in order to be able to do this?

United Kingdom;
Ireland (Republic of);

Australia;
Canada;
United States of America;

Afghanistan;
Albania;

Algeria;
Andorra;
Angola;
Anguilla;
Antiga & Barbuda;
Argentina;

Armenia;
Aruba;
Ascension;
Austra;
Azerbaijan;
Azores;

Bahamas;
Bahrain;
Balearic Islands;
Bangladesh;
Barbados;
Belarus;

Belgium;
Belize;
Benin;
Bermuda;
Bhutan;
Bolivia;

Bosnia-Herzegovina;
Botswana;
Brazil;
British Virgin Islands;
Brunei Darussalam;
Bulgaria;

Burkina Faso;
Burundi;
Cambodia;
Cameroon;
Canary Islands;
Cape Verde;

Cayman Islands;
Central African Republic;
Chad;
Chile;
China;
Christmas Island;

Cocos Island;
Columbia;
Comoros;
Congo, Democratic Rep. of;
Congo (People's Rep.);
Corsica;

Costa Rica;
Croatia;
Cuba;
Cyprus;
Czech Republic;

Denmark;
Djibouti;
Dominica;
Dominican Republic;
East Timor;
Ecuador;

Egypt;
El Salvador;
Equatorial Guinea;
Eritrea;
Estonia;
Ethiopia;

Falkland Islands;
Faroe Islands;
Fiji;
Finland;
France;
French Guiana;

French Polynesia;
Gabon;
The Gambia;
Gaza & Khan Yunis;
Georgia;
Germany;

Ghana;
Gibraltar;
Greece;
Greenland;
Grenada;
Guadeloupe;

Guam;
Guatemala;
Guinea (Republic of);
Guinea-Bissau;
Guyana;
Haiti2;

Honduras;
Hong Kong;
Hungary";
Iceland;
India;
Indonesia;

Iran (Islamic Republic);
Iraq;
Israel;
Italy;
Ivory Coast Cote d'Ivoire;
Jamaica;

Japan;
Jordan;
Kazakhstan;
Kenya;
Kirghizstan;
Kiribati;

Korea, Republic of (South);
Kuwait;
Laos;
Latvia;
Lebanon;
Lesotho;

Liberia;
Libya;
Liechtenstein;
Lithuania;
Luxembourg;
Macao;

Macedonia;
Madagascar;
Madeira;
Malawi;
Malaysia;
Maldives;

Mali;
Malta;
Marshall Islands;
Martinique;
Mauritania;
Mauritius;

Mexico;
Micronesia;
Moldova;
Monaco;
Mongolia;
Montserrat;

Morrocco;
Mozambique;
Myanmar (Burma);
Namibia;
Nauru;
Nepal;

Netherland;
Netherlands Antilles;
New Caledonia;
New Zealand;
New Zealand Island Ter.;
Nicaragua;

Niger;
Nigeria;
Norfolk Island;
Northern Mariana Islands;
Norway;
Oman;

Pakistan;
Panama;
Papua New Guinea;
Paraguay;
Peru;
Philippines;

Pitcairn Islands;
Poland;
Portugal;
Puerto Rico;
Qatar;
Reunion;

Romania;
Russia;
Rwanda;
St Christopher & Nevis;
St Helena;
St Lucia;

St Pierre & Miquelon;
St Vincent and Grenadines;
Samoa;
San Marino;
Sao Tome & Principe;

Sardinia;
Saudi Arabi;
Senegal;
Seyshelles;
Sicily;
Sierra Leone;

Singapore;
Slovakia;
Slovenia;
Soloman Islands;
Somali;
South Africa;

Spain;
Spanish Territories of N Africa;
Spitzbergen">Spitzbergen;
Sri Lanka;
Sudan;
Suriname;

Swaziland;
Sweden;
Switzerland
Syria;
Tiawan;
Tajikistan;

Tanzania;
Thailand;
Togo;
Tonga;
Trinidad & Tobago;
Tristan da Cunha;

Tunisia;
Turkey3;
Turkmenistan;
Turks & Caicos Islands;
Tuvalu;
Uganda;

Ukraine;
United Arab Emirates;
Uruguay;
Uzbekistan;
Vanuatu;
Vatican City State;

Venezuela;
Vietnam;
Virgin Islands (USA);
Wake Island;
Wallis & Futuna Islands;
Western Samo;

Yemen;
Yugoslavia;
Zambia;
Zimbabwe;
 
wow thanks very much fishfluff and Augmented. I too have learnt something today, I used Augmenteds method. Though I appreciate the work it took fishfluff to do your method. I thank you lots both! Cheers!
 
Back
Top Bottom