Hello everybody,

In an earlier post I created an bingocard with random numbers. The card should have 6 rows and 6 columns.
I get 6 rows and 10 columns.
I am trying to adjust the columns, but with my script now it prints on each row the first number till the last number of the card 3 times.
I can't solve the problem, somewhere I make a mistake but can't figure out where.
Could someone help?

<html>
<body>

<?php
mt_srand((double)microtime()*1000000);
//Een bijzondere aanpak voor het vullen
function Vullen()
{
    $getallen = array(0,1,2,3,4,5,6,7,8,9);
    shuffle($getallen);
    return $getallen;

}

$getallen = Vullen(); 

//De functie display is om de getallen aan de rijnummers te koppelen: dus 1 + 0 t/m 9 voor rij 1 en 2 + 0 t/m 9 voor rij twee etc
function display($getallen){
    $table = '<table  border="1px" cellpadding="1px">';
    $bingokaart = array();

    for ($row = 1; $row < 7; ++$row){

        $bingokaart[$row] = array();

        $table .= '<tr>';

        //Hier print je de getallen en de rijen : Echter nu 6 rijen en 10 columns!
        foreach ($getallen as $number){

        //for rownumber? Here it goes wrong? Now it prints on each row three times the number
            for ($rownumber = 0; $rownumber < 3 ; ++$rownumber ){
                $bingokaart[$row] = $row .$number;  

            $table .= '<td>'  . $bingokaart[$row]  . '</td>';
                    }
        }
        $table .= '</tr>';
    }
    $table .='</table>';

    echo $table;
}

display($getallen);

?>

</body>
</html>

Recommended Answers

All 2 Replies

Try this

<html>
<body>

<?php
mt_srand((double)microtime()*1000000);
//Een bijzondere aanpak voor het vullen
function Vullen()
{
    $getallen = array(0,1,2,3,4,5,6,7,8,9);
    shuffle($getallen);
    return $getallen;

}

$getallen = Vullen(); 

//De functie display is om de getallen aan de rijnummers te koppelen: dus 1 + 0 t/m 9 voor rij 1 en 2 + 0 t/m 9 voor rij twee etc
function display($getallen){
    $table = '<table  border="1px" cellpadding="1px">';
    $bingokaart = array();
    for ($row = 1; $row < 7; ++$row){
$columnCount=0;
        $bingokaart[$row] = array();

        $table .= '<tr>';

        //Hier print je de getallen en de rijen : Echter nu 6 rijen en 10 columns!
        foreach ($getallen as $number){

        //for rownumber? Here it goes wrong? Now it prints on each row three times the number
           /* for ($rownumber = 0; $rownumber < 3 ; ++$rownumber ){*/
                if($columnCount<6){
                $bingokaart[$row] = $row .$number;  

            $table .= '<td>'.$bingokaart[$row]  . '</td>';
                    }

                    /*}*/
                    $columnCount++;
        }

        $table .= '</tr>';
    }
    $table .='</table>';

    echo $table;
}

display($getallen);

?>

</body>
</html>

Hi Bachu,

That works, but if I want an invisible 7th column, is that possible.
I would like to save the drawn numbers in row 7 and column 7 invisible and check each draw if there is Bingo.
I will work this out, but help is appriciated.

Greetings

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.