You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
onthedots/code/highscores.php

113 lines
5.2 KiB

<head>
<link rel="stylesheet" type="text/css" href="highscores.css"/>
</head>
<form action="highscores.php" method="post">
<div id="modeSelection">
<ul id="modes">
<img id="img_points" class="button" src="./ress/button_mode_points.png"/>
<img id="img_temps" class="button" src="./ress/button_mode_temps.png"/>
<img id="img_survie" class="button" src="./ress/button_mode_survie.png"/>
</ul>
<ul id="points" class="all-container">
<input type="radio" class="rad" name="game_mode" id="5p" value="5p" />
<label for="5p"><img id="img_5p" class="button" src="./ress/button_points_5.png"/></label>
<input type="radio" class="rad" name="game_mode" id="10p" value="10p"/>
<label for="10p"><img id="img_10p" class="button" src="./ress/button_points_10.png"/></label>
<input type="radio" class="rad" name="game_mode" id="15p" value="15p" />
<label for="15p"><img id="img_15p" class="button" src="./ress/button_points_15.png"/></label>
<input type="radio" class="rad" name="game_mode" id="20p" value="20p" />
<label for="20p"><img id="img_20p" class="button" src="./ress/button_points_20.png"/></label>
</ul>
<ul id="temps" class="all-container">
<input type="radio" class="rad" name="game_mode" id="5m" value="5m" />
<label for="5m"><img id="img_5m" class="button" src="./ress/button_temps_5.png"/></label>
<input type="radio" class="rad" name="game_mode" id="10m" value="10m"/>
<label for="10m"><img id="img_10m" class="button" src="./ress/button_temps_10.png"/></label>
</ul>
<ul id="survie" class="all-container">
<input type="radio" class="rad" name="game_mode" id="15s" value="15s"/>
<label for="15s"><img id="img_15s" class="button" src="./ress/button_survie_15.png"/></label>
<input type="radio" class="rad" name="game_mode" id="30s" value="30s" />
<label for="30s"><img id="img_30s" class="button" src="./ress/button_survie_30.png"/></label>
<input type="radio" class="rad" name="game_mode" id="45s" value="45s" />
<label for="45s"><img id="img_45s" class="button" src="./ress/button_survie_45.png"/> </label>
</ul>
</div>
<ul id="diff" class="all-container">
<input type="radio" class="rad" name="difficulty" id="easy" value="easy" />
<label for="easy"><img id="img_easy" class="button" src="./ress/button_diff_easy.png"/></label>
<input type="radio" class="rad" name="difficulty" id="med" value="med" />
<label for="med"><img id="img_med" class="button" src="./ress/button_diff_normal.png"/></label>
<input type="radio" class="rad" name="difficulty" id="hard" value="hard" />
<label for="hard"><img id="img_hard" class="button" src="./ress/button_diff_hard.png"/></label>
</ul>
<div>
<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>
</div>
<p>Changer le nombre de points</p>
<input type="range" min="2" max="8" class="slider" name="dotsAmount" id="range_dots">
<p>Nombre de points : <span id="dotsNumber"></span></p>
<input type="image" src="ress/button_highscores.png" alt="Submit" id="btn_high">
<img id="btn_high_des" src="ress/button_highscores_desac.png"/>
</form>
Entrez votre pseudo (optionnel, mais n&eacute;cessaire si vous voulez sauvegarder votre score): <br/>
<input type="text" id="field_pseudo" /><br/>
<img id="btn_play" src="ress/button_play.png" onClick="play()"/>
<img id="btn_play_des" src="ress/button_play_desac.png"/>
<script src="bakery.js"></script>
<script src="highscore_button_displayer.js"></script>
<?php
$database = new SQLite3("data.db");
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 min(score) from score where game_mode="'.$_POST['game_mode'].'" and difficulty="'.$_POST['difficulty'].'" and dots_amount='.$_POST["dotsAmount"].' and pause='.$_POST["pause"].')';
}
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 max(score) from score where game_mode="'.$_POST['game_mode'].'" and difficulty="'.$_POST['difficulty'].'" and dots_amount='.$_POST["dotsAmount"].' and pause='.$_POST["pause"].')';
}
$result = $database->query($sql);
$a=$result->fetchArray();
if($a==false)
{
$phrase= "Il n'y a pas encore de score pour ce mode de jeu.";
}
else
{
$phrase="Le record est ".$a[0].", tenu par ".$a["player"];
while ($row = $result->fetchArray()) {
$phrase=$phrase.", ".$row["player"];
}
}
echo "<h1 id='aya'>".$phrase."</h1>";
}
?>