djcrisp22 Posted September 9, 2008 Share Posted September 9, 2008 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>"; ?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 9, 2008 Share Posted September 9, 2008 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>"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.