affichage 5 meilleurs scores

master
adplantade 5 years ago
parent f0f46b4617
commit d38dd0b6e5

@ -119,16 +119,18 @@
$database = new SQLite3("data.db"); $database = new SQLite3("data.db");
// echo isset($_POST["game_mode"])." ".isset($_POST["difficulty"])." ".isset($_POST["dotsAmount"])." ".isset($_POST["pause"]); // 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(isset($_POST["game_mode"]) && $_POST["game_mode"]!="" && $_POST["difficulty"]!="" && $_POST["dotsAmount"]!="" && $_POST["pause"]!="")
{ {
if(stristr($_POST['game_mode'], "p") === FALSE) 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 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); $result = $database->query($sql);
$a=$result->fetchArray(); $a=$result->fetchArray();
@ -139,9 +141,12 @@ if(isset($_POST["game_mode"]) && $_POST["game_mode"]!="" && $_POST["difficulty"]
} }
else 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()) { while ($row = $result->fetchArray()) {
$phrase=$phrase.", ".$row["player"];
$phrase=$phrase."</br>".$cpt."° place : ".$row["player"].", ".$row["score"]." ".$unit;
$cpt++;
} }
} }

@ -1,12 +1,13 @@
<ul> <?php
<p>Mode pause activé : </p>
<input type="radio" id="pause1" value="1" name="pause"> $database = new SQLite3("data.db");
<label for="pause1">Oui</label> $sql='select score, player from score where difficulty="easy" order by score desc limit 5';
<input type="radio" id="pause0" value="0" name="pause"> $result = $database->query($sql);
<label for="pause0">Non</label> //$a=$result->fetchArray();
<p>Changer le nombre de points</p>
<img src="ress/-" onClick="less()" id="-"/> $phrase="|";
<span id="dotsNumber"></span> while ($row = $result->fetchArray()) {
<img src="ress/+" onClick="more()" id="+"/> $phrase=$phrase."</br> ".$row["player"].":".$row["score"];
<input type="hidden" name="dotsAmount" id="amountHi"/> }
</ul> echo $phrase;
?>
Loading…
Cancel
Save