diff --git a/lib/php/public/getJsonVotes.php b/lib/php/public/getJsonVotes.php new file mode 100644 index 00000000..130aedf6 --- /dev/null +++ b/lib/php/public/getJsonVotes.php @@ -0,0 +1,48 @@ + 0){ + $nbObservationsToReturn = $_GET['nb2return']; + } + $sql = "SELECT count(*) as nb_votes, poi_poi_id, lib_subcategory, lib_pole, lib_territoire + FROM `support_poi` + INNER JOIN poi ON poi.id_poi = support_poi.poi_poi_id + INNER JOIN pole ON poi.pole_id_pole = pole.id_pole + INNER JOIN territoire ON pole.territoire_id_territoire = territoire.id_territoire + INNER JOIN subcategory ON poi.subcategory_id_subcategory = subcategory.id_subcategory + GROUP BY poi_poi_id + ORDER BY nb_votes desc + LIMIT " . $nbObservationsToReturn; + + $result = mysql_query($sql); + $i = 0; + + while ($row = mysql_fetch_array($result)){ + $arr[$i]['nbVotes'] = $row['nb_votes']; + $arr[$i]['id_poi'] = $row['poi_poi_id']; + $arr[$i]['url'] = URL."/index.php?id=".$row['poi_poi_id']; + $arr[$i]['categorie'] = $row['lib_subcategory']; + $arr[$i]['territoire'] = $row['lib_territoire'] . " " . $row['lib_pole']; + $i++; + } + echo '{"statistiques":'.json_encode($arr).'}'; + + mysql_free_result($result); + mysql_close($link); + break; + case 'postgresql': + // TODO + break; + } + +?> \ No newline at end of file