affichage 5 meilleurs scores

master
adplantade 5 years ago
parent f0f46b4617
commit d38dd0b6e5

@ -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."</br>".$cpt."° place : ".$row["player"].", ".$row["score"]." ".$unit;
$cpt++;
}
}

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