Multi columns - code validation

2 posts by 2 authors in: Forums > CMS Builder
Last Post: June 22, 2011   (RSS)

By Mikey - June 22, 2011

I'm using the multi-column code seen below for a photo gallery showing 8 photos. The first 7 photos build perfectly, but the 8th photo has a bit of stray code </tr><tr> </tr> </table>at the very end. Is it possible to keep the multi-columns from producing un-needed code for the last column so the webpage will validate? See below for more details:

<table border="0" id="gallery" cellspacing="0" cellpadding="12" align="center">
<tr valign="middle">
<?PHP foreach ($photo_galleryRecords as $record): ?><?PHP foreach ($record['image'] as $upload):
?>
<td align="center" valign="middle" <?PHP echo $record['border'] ?> width="15%">
<div align="center">
<?PHP if ($upload['hasThumbnail']): ?>
<a href="<?PHP echo $upload['urlPath'] ?>" rel="lightbox" title=<a href=&quot;<?PHP
echo $record['_link'] ?>&quot;><h2><?PHP echo $record['title'] ?></h2></a><br>Click the title for
more info.<?PHP endif ?>">
<img src="<?PHP echo $upload['thumbUrlPath'] ?>" width="<?PHP echo $upload['thumbWidth']
?>" height="<?PHP echo $upload['thumbHeight']?>" /></a>
<?PHP endif; ?>
</div>

</td>
<?php $maxCols=4; if (@++$count % $maxCols == 0): ?></tr><tr><?php endif; ?><?php endforeach ?><?php endforeach ?>
<?php ?>
</tr>
</table>
<!-- /listing columns -->


And when I use the http://validator.w3.org website code validator, I get the following message seen below.

Line 502, Column 18: end tag for "tr" which is not finished

</tr><tr> </tr>

Most likely, you nested tags and closed them in the wrong order. For example <p><em>...</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>...</em></p>

Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, in HTML the <head> element must contain a <title> child element, lists require appropriate list items (<ul> and <ol> require <li>; <dl> requires <dt> and <dd>), and so on.


So I viewed my source code of my live webpage and see that the last column is producing stray (</tr><tr>) that are not being used, which is causing the page not to validate. Is it possible to keep the mulit-column code from producing the stray unused (</tr><tr>) on the last column being produced?

</div>

</td>
</tr><tr> </tr>
</table>
<!-- /listing columns -->