-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathincrement.php
45 lines (36 loc) · 1.14 KB
/
increment.php
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
<?php
//Developpé par stephane.
//réveil dans 5h bordel, j'ai eu un flash dans la nuit j'ai juste simplifié le code.
include_once 'back/DBconnect.php';
echo "salut";
$dbh = new PDO('mysql:host=localhost;dbname=streetmap', $user, $pass);
$req = $dbh->query('SELECT * from streetmap');
$f = fopen("villesetmessages.json","w+");
fwrite($f, "{ \r\n \"histoire\": [ \r\n");
$nmb = $req->rowCount();
$i = 0;
while($donnees = $req->fetch()) {
$i++;
if($i < $nmb)
{
fwrite($f, "{\n
\"ID\": \"".$donnees['ID']."\",\n
\"pays\": \"".$donnees['pays']."\",\n
\"ville\": \"".$donnees['ville']."\",\n
\"coordonees\": ".$donnees['coordonees'].",\n
\"nombredemessage\": ".$donnees['nbmsg']."\n
},");
} elseif($i = $nmb)
{
fwrite($f, "{\n
\"ID\": \"".$donnees['ID']."\",\n
\"pays\": \"".$donnees['pays']."\",\n
\"ville\": \"".$donnees['ville']."\",\n
\"coordonees\": ".$donnees['coordonees'].",\n
\"nombredemessage\": ".$donnees['nbmsg']."\n
} \n");
}
}
fwrite($f, " ]\n }\n");
fclose($f);
?>