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>";

        ?>


Link to comment
Share on other sites

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>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.