diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ab59ee9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.html +barometre.sqlite \ No newline at end of file diff --git a/barometre.php b/barometre.php index 4d2186f..f524abe 100644 --- a/barometre.php +++ b/barometre.php @@ -1,3 +1,10 @@ + + + + Suivi du baromètre + + + fetchArray()) { echo "{$line['nom']}{$line['nombre']}\n"; } ?> - - +
+
+query("SELECT * FROM chiffres c natural join villes v WHERE v.nom != 'Angers'"); +$dataset = []; +while($line = $data->fetchArray()) { + if (!key_exists($line['code_INSEE'], $dataset)) { + $dataset[$line['code_INSEE']]['type'] = 'line'; + $dataset[$line['code_INSEE']]['label'] = $line['nom']; + $dataset[$line['code_INSEE']]['tension'] = 0.1; + } + $dataset[$line['code_INSEE']]['data'][] = array('x' => date_format(date_create($line['date']), 'Y/m/d H:i'), 'y'=>$line['nombre']); +} +$decoded = []; +foreach($dataset as $value) { $decoded[] = $value; } +$json = json_encode($decoded); +?> + +
+
+query("SELECT * FROM chiffres c natural join villes v WHERE v.nom == 'Angers'"); +$dataset_angers = []; +while($line = $data->fetchArray()) { + $dataset_angers[] = array('x' => date_format(date_create($line['date']), 'Y/m/d H:i'), 'y'=>$line['nombre']); +} +$json_angers = json_encode($dataset_angers); +?> + +
Le code correspondant au script
+ + \ No newline at end of file diff --git a/barometre.sqlite b/barometre.sqlite index ea04d7f..45b6402 100644 Binary files a/barometre.sqlite and b/barometre.sqlite differ