Jump to content

[SOLVED] need to create a blank cell block?


djcrisp22

Recommended Posts

i am new here in this forum.  i have this problem creating a cell that needs to be empty? here is my code.  this will create a table.  on the very first block, how can i get it to be empty.  and also add color? for example, the whole first vertical and horizontal row to be colored and numbered from 1 to 12.  and the first block needs to be empty?  any help is appreciated. if u can give me any hints.  php is very difficult to learn. thanks in advance :)

 



<?php 

echo "<table style=\"border: 1px solid black;\"> \n";

for ($y=1; $y<=12; $y++) {

    echo "<tr> \n";

     for ($x=1; $x<=12; $x++) {

           echo "<td style=\"border: 1px solid #000; width: 25px; padding: 4px;

                       text-align:center;\">";

              echo ($x * $y);

              echo "</td> \n";

        }

          echo "</tr> \n";

             }

       echo "</table>";

        ?>


echo "<table style=\"border: 1px solid black;\">\n";

$max_cols = 12;
$max_rows = 12;

for ($row=0; $row<=$max_rows; $row++)
{
    echo "<tr>\n";

    for ($col=0; $col<=$max_cols; $col++)
    {
        if ($col==0 || $row==0)  //Header cell
        {
            echo "<th style=\"background-color:#cecece;\">";
            if ($row==0 && $col==0)
            {
                echo " "; //Blank cell for top left
            } else
            {
                echo (($row==0) ? $col : $row) ; //Display row/column header
            }
            echo "</th>";
        }
        else //data cell
        {
            echo "<td style=\"border: 1px solid #000; width: 25px; padding: 4px; text-align:center;\">";
            echo ($row * $col);
            echo "</td>";
        }
    }

    echo "</tr>\n";
}

echo "</table>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.