diff --git a/code/index.php b/code/index.php index b3a5735..9fcc5ba 100644 --- a/code/index.php +++ b/code/index.php @@ -119,16 +119,18 @@ $database = new SQLite3("data.db"); // echo isset($_POST["game_mode"])." ".isset($_POST["difficulty"])." ".isset($_POST["dotsAmount"])." ".isset($_POST["pause"]); - +$toDisp=5; if(isset($_POST["game_mode"]) && $_POST["game_mode"]!="" && $_POST["difficulty"]!="" && $_POST["dotsAmount"]!="" && $_POST["pause"]!="") { if(stristr($_POST['game_mode'], "p") === FALSE) { - $sql='select score, player from score where game_mode="'.$_POST['game_mode'].'" and difficulty="'.$_POST['difficulty'].'" and dots_amount='.$_POST["dotsAmount"].' and pause='.$_POST["pause"].' and score=(select max(score) from score where game_mode="'.$_POST['game_mode'].'" and difficulty="'.$_POST['difficulty'].'" and dots_amount='.$_POST["dotsAmount"].' and pause='.$_POST["pause"].')'; + $sql='select score, player from score where game_mode="'.$_POST['game_mode'].'" and difficulty="'.$_POST['difficulty'].'" and dots_amount='.$_POST["dotsAmount"].' and pause='.$_POST["pause"].' order by score desc limit '.$toDisp; + $unit="points"; } else { - $sql='select score, player from score where game_mode="'.$_POST['game_mode'].'" and difficulty="'.$_POST['difficulty'].'" and dots_amount='.$_POST["dotsAmount"].' and pause='.$_POST["pause"].' and score=(select min(score) from score where game_mode="'.$_POST['game_mode'].'" and difficulty="'.$_POST['difficulty'].'" and dots_amount='.$_POST["dotsAmount"].' and pause='.$_POST["pause"].')'; + $sql='select score, player from score where game_mode="'.$_POST['game_mode'].'" and difficulty="'.$_POST['difficulty'].'" and dots_amount='.$_POST["dotsAmount"].' and pause='.$_POST["pause"].' order by score asc limit '.$toDisp; + $unit="secondes"; } $result = $database->query($sql); $a=$result->fetchArray(); @@ -139,10 +141,13 @@ if(isset($_POST["game_mode"]) && $_POST["game_mode"]!="" && $_POST["difficulty"] } else { - $phrase="Le record est ".$a[0].", tenu par ".$a["player"]; + $phrase="1° place : ".$a["player"].", ".$a[0]." ".$unit; + $cpt=2; while ($row = $result->fetchArray()) { - $phrase=$phrase.", ".$row["player"]; - } + + $phrase=$phrase."
".$cpt."° place : ".$row["player"].", ".$row["score"]." ".$unit; + $cpt++; + } } diff --git a/code/phpinfo.php b/code/phpinfo.php index d42ae5c..675e586 100644 --- a/code/phpinfo.php +++ b/code/phpinfo.php @@ -1,12 +1,13 @@ - \ No newline at end of file +query($sql); +//$a=$result->fetchArray(); + +$phrase="|"; +while ($row = $result->fetchArray()) { + $phrase=$phrase."
".$row["player"].":".$row["score"]; +} +echo $phrase; +?> \ No newline at end of file