1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
<html>
<head><title>Création BDD</title></head>
<meta http-equiv="Content-Type" content="text/html"; charset="utf_8" />
<body>
<? echo 'début création<br><br> ';
$connect=mysql_connect ("127.0.0.1","root", "toto");
if ($connect==true) { echo 'connexion réussie<br><br>'; } else { echo 'echec connexion';}
mysql_query("drop database aurel");
mysql_query("create database aurel");
mysql_query("use aurel");
mysql_query("CREATE TABLE typecontact
( codetype integer PRIMARY KEY,
libelletype char(35));");
mysql_query("CREATE TABLE region
( nomregion char(35) PRIMARY KEY);");
mysql_query("CREATE TABLE departement
( codedep integer PRIMARY KEY,
nomdep char(35),
region char(35));");
mysql_query("CREATE TABLE ville
( codepostal integer PRIMARY KEY,
nomville char(50),
codedepartement integer);");
mysql_query("CREATE TABLE societe
( codesoc integer auto_increment PRIMARY KEY,
nomsoc char(50),
adrsoc char(50),
codepostalsoc integer,
numfixesoc char(14),
numtelecopiesoc char(14),
pagewebsoc char(80),
emailsoc char(80));");
mysql_query("CREATE TABLE contact
( numcontact integer auto_increment PRIMARY KEY,
nomcontact char(50),
prenomcontact varchar(30),
adrcontact char(30),
codepos integer,
numfixe char(14),
numportable char(14),
email char(30));");
$Fnm = "../../../../www/contact.txt";
$inF = fopen($Fnm,"r+");
$tableau = file($Fnm);
while(list($cle,$val) = each($tableau)) {
utf8_encode($val);
echo ($val),"<br>";
}
/*$fp = fopen("../../../../www/contact.txt","r+");
$donnees = fgets($fp,255);
$don=utf8_encode($donnees);
echo ($don),'<br><br>';
$dondeux= fgets($fp,255);*/
mysql_query("charset utf8");
$enc=mysql_client_encoding();
echo 'Charset MySQL : ',($enc),'<br>';
mysql_query("INSERT INTO contact (numcontact,nomcontact,prenomcontact,adrcontact,codepos,numfixe,numportable,email) VALUES (4,'RODRIGO','Aurélien','7 bd président Wilson',94230,'01 46 63 60 86','06 15 98 52 84','aurelviot@yahoo.fr')");
//echo'Le fichier contient : ',$donnees,'<br><br>';
mysql_query("LOAD DATA INFILE '../../../../www/region.txt' INTO TABLE region LINES TERMINATED BY '\r\n';");
mysql_query("LOAD DATA INFILE '../../../../www/departement.txt' INTO TABLE departement FIELDS TERMINATED BY ';' LINES TERMINATED BY '\r\n';");
mysql_query("LOAD DATA INFILE '../../../../www/typecontact.txt' INTO TABLE typecontact FIELDS TERMINATED BY ';' LINES TERMINATED BY '\r\n';");
mysql_query("LOAD DATA INFILE '../../../../www/societe.txt' INTO TABLE societe FIELDS TERMINATED BY ';' LINES TERMINATED BY '\r\n';");
mysql_query("LOAD DATA INFILE '../../../../www/contact.txt' INTO TABLE contact FIELDS TERMINATED BY ';' LINES TERMINATED BY '\r\n';");
mysql_query("LOAD DATA INFILE '../../../../www/ville.txt' INTO TABLE ville FIELDS TERMINATED BY ';' LINES TERMINATED BY '\r\n';");
echo 'fin creation';
mysql_close();
?>
</body>
</html> |
Partager