宾果游戏 - 如何点击/显示选秀权

时间:2018-06-05 07:18:55

标签: php html css arrays post

我试图用HTML,CSS和&amp ;;创建一个宾果游戏PHP(没有Javascript)。用户可以在计算机上玩宾果游戏。用户必须能够在表格中指明数字。但我不确切知道如何在实践中解决这个问题。

这是我到目前为止所做的:

<!DOCTYPE html>
<html>
<head>
    <title>bingo</title>
</head>
<body>

<?php

if (empty($_POST)) {

    $players = array('computer', 'opponent');
    $picks = array();

    for ($i = 1; $i < 16; $i++) 
    {
        $numbers['B'][] = $i;
        $numbers['I'][] = $i+15;
        $numbers['N'][] = $i+30;
        $numbers['G'][] = $i+45;
        $numbers['O'][] = $i+60;
    }

    $letters = array ('B','I','N','G','O');
    foreach ($letters as $letter) {

        foreach($players as $player)
        {
            shuffle($numbers[$letter]);

            $chunks = array_chunk($numbers[$letter], 5);
            $cards[$player][$letter] = $chunks[0];

            if ($letter == 'N') {
                $cards[$player][$letter][2] = ' * '; // *
            }
        } 
    }

    $cardsstr = serialize($cards);
    $picksstr = serialize($picks);

}
else
{

}

?>


Getrokken nummers : <?php echo implode(',', $picks) ?>


<form method='post'>
<input type='hidden' name='cardsstr' value='<?php echo $cardsstr ?>' />
<input type='hidden' name='ballsstr' value='<?php echo $ballsstr ?>' />
<input type='hidden' name='picksstr' value='<?php echo $picksstr ?>' />
<input type='submit' name='cards' value='next number' />
</form>
<a href="bingo2_niels.php">Start Over</a>

<?php

foreach ($cards as $key => $value) 
{
    // Show player
    echo "<h2>" . $key . "</h2>";

    // Start table
    echo "<table border='1'>";

    echo "<tr><td>B</td><td>I</td><td>N</td><td>G</td><td>O</td></tr>";

    for ($i = 0; $i < 5; $i++) {
        echo "<tr>
                <td>" . $value['B'][$i] . "</td>
                <td>" . $value['I'][$i] . "</td>
                <td>" . $value['N'][$i] . "</td>
                <td>" . $value['G'][$i] . "</td>
                <td>" . $value['O'][$i] . "</td>
            </tr>";
    }

    echo "</table>";
}

?>

</body>
</html>

它的外观如下:

enter image description here

但现在我正在努力思考如何选择表中的数字并显示它们何时被选中。你能救我吗?

0 个答案:

没有答案