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
| <?php
$mysqli = new mysqli('localhost', 'root', '', 'projet_meteo');
$mysqli->set_charset("utf8");
if ($mysqli->connect_errno) {
echo 'Echec de la connection' . $mysqli->connect_error;
exit();
}
if (($handle = fopen("meteo.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$data_utf8=[];
// var_dump($data);
// die();
foreach($data as $item_data){
$var=str_replace('é','e',$item_data);
$data_utf8[]=str_replace('è','e',$var);
}
$date = $data_utf8[0];
$ville = $data_utf8[1];
$periode = $data_utf8[2];
$resume = $data_utf8[3];
$id_resume = $data_utf8[4];
$temp_min = $data_utf8[5];
$temp_max = $data_utf8[6];
$commentaire = $data_utf8[7];
$mysqli->query('INSERT INTO meteo (day, ville, periode, resume, id_resume, temp_min, temp_max, commentaire) VALUES ("'. $date .'" , "'. $ville .'" ,"'. $periode .'" , "'. $resume .'" , "'. $id_resume .'" , "'. $temp_min .'" , "'. $temp_max .'" , "'. $commentaire .'")');
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<table align="center" border="1px" style="width:1000px; line-height:40px">
<tr>
<th colspan="8"><h2>Prévisions météo sur Paris</h2></th>
</tr>
<t>
<th>Date</th>
<th>Ville</th>
<th>Période</th>
<th>Resumé</th>
<th>ID résumé</th>
<th>Temps minimum</th>
<th>Temps Maximum</th>
<th>Commentaire</th>
</t>
<tr>
<td><?php echo $data_utf8[0];?></td>
<td><?php echo $data_utf8[1];?></td>
<td><?php echo $data_utf8[2];?></td>
<td><?php echo $data_utf8[3];?></td>
<td><?php echo $data_utf8[4];?></td>
<td><?php echo $data_utf8[5];?></td>
<td><?php echo $data_utf8[6];?></td>
<td><?php echo $data_utf8[7];?></td>
</tr>
</table>
</body>
</html> |
Partager