jeudi 22 octobre 2015

How to create random table grid wtih php?

i am new at php.I need randomized numbers from a pool to be seen in table. i created with for loops but couldnt fill with all random numbers. rigth now unfortunately all cells show same number.

  <?php
    $size = 3;
    $no = array(0,1,2,3,4,5,6,7,8,9,2,4,6,8);
    ?>
    <table>
    <?php 
    $number[] = $no[array_rand($no)];
        for ($i=0; $i < $size; $i++){
            foreach ($number as $cell)
        { ?><tr><?php
            for ($b=0; $b < $size ;$b++){
             foreach ($number as $cell){
        echo '<td>'.$cell.'</td>';
          }
         }
         }
         ?></tr><?php
        }
        ?>
        </table>




Aucun commentaire:

Enregistrer un commentaire