iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 24
0

猜到正解後首先會出現這個畫面,會在5秒後自動跳轉到排行榜的頁面:
https://ithelp.ithome.com.tw/upload/images/20191008/20120024AI9GhPAHYo.png
correct.php


<body>
<div class="flex-center position-ref full-height ">
    <div class="top-right home">
        <a href="index.php">Restart</a>
        <a href="rank.php">RANK</a>
    </div>

    <div class="content">
        <div class="m-b-md">
            <div class="title">

                <?="Answer Correct, <br> Congratulations ".$name."!!";
                echo"<br>You spent ".$spentMin. " minutes and ".$spentSec." seconds.";
                header("Refresh:5;url=rank.php");

                ?>
            </div>

        </div>
    </div>

</body>
</html>

接著進入排行榜,排序參考的是時間(分.秒)+總共猜的次數,由小至大排序:
https://ithelp.ithome.com.tw/upload/images/20191008/201200245Q7IK6mXRm.png
rank.php

<title>Rank</title>
<body>
<div class="flex-center position-ref full-height ">
    <div class="top-right home">
        <a href="index.php">Restart</a>
    </div>

    <div class="contentR m-b-md">
        <div class="title">
            Rank
        </div>
<?php
include 'style.html';
include 'db.php';
$sql1 = "select * from rank ";
$result = mysqli_query($db, $sql1);

$sql = "select * from rank ORDER BY total ";
$result = mysqli_query($db, $sql);?>
<div class="rank">
        <div class="title1">
            <div class="title1__rank">排名</div>
            <div class="title1__playerName">玩家</div>
            <div class="title1__times">次數</div>
            <div class="title1__time">時間</div>
        </div>
<?php
$i = 1;
while ($row = mysqli_fetch_assoc($result)) {
    echo '<div class="player">';
    echo '<div class="player__rank">No.'.$i."</div>";
    echo '<div class="player__name">'.$row['name']."</div>";
    echo '<div class="player__times">'.$row['times']."</div>";
    echo '<div class="player__time">'.$row['min'].":".$row['sec']."</div>";
    echo '</div>';
    $i++;
}
header("Refresh:5;url=index.php")
?>

同樣會在5秒後自動跳轉到一開始輸入玩家名稱的地方,並將儲存剛才所猜的數字與線索的table以及所作的筆記清空。
https://ithelp.ithome.com.tw/upload/images/20191008/201200242bgmzgEmFx.png


上一篇
Day 23 實做猜數字遊戲(三):產生答案及線索
下一篇
Day 25 什麼是RESTful API?
系列文
後端基礎PHP+Mysql & Laravel 30日養成計畫36
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言