title: How to change colspan and rowspan dynamically without causing harm to table structure
body: <p>When I attempt to give rowspan dynamically to the <code>&lt;td&gt;</code>
  (adding rowspan depends upon values from the db) I am getting the table as below.
  An extra column is appearing (3::::3 ,4::::3) which I don't want.
  How do I stop this extra column from appearing?</p>
  
  <pre><code>&lt;?php
   $time = array (
    "06.00 - 07.00",
    "07.00 - 08.00",
    "08.00 - 09.00",
    "09.00 - 10.00",
    "10.00 - 11.00",
    "11.00 - 12.00",
    "12.00 - 01.00",
    "01.00 - 02.00",
    "02.00 - 03.00",
    "03.00 - 04.00"
   );
  ?&gt;
  &lt;table border = "1"&gt;
   &lt;tr&gt;&lt;th&gt;time&lt;/th&gt;&lt;th&gt;room1&lt;/th&gt;&lt;th&gt;room2&lt;/th&gt;&lt;th&gt;room3&lt;/th&gt;&lt;/tr&gt;
  &lt;?php
   for ($i = 1; $i &lt;= 10; $i++) {
  ?&gt;
   &lt;tr&gt;
    &lt;td&gt;&lt;?php echo $time [$i - 1]; ?&gt;&lt;/td&gt;
  &lt;?php
    for ($j = 1; $j &lt;= 3; $j++) {
  ?&gt;
    &lt;td&lt;?php if (($i == 2) &amp;&amp; ($j == 3)) {echo ' rowspan="3"';} ?&gt;&gt;&lt;?php echo $i . "::::" . $j; ?&gt;&lt;/td&gt;
  &lt;?php
    }
  ?&gt;
   &lt;/tr&gt;
  &lt;?php
   }
  ?&gt;
  &lt;/table&gt;
  </code></pre>