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:
And when I use the http://validator.w3.org website code validator, I get the following message seen below.
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?
<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="<?PHP
echo $record['_link'] ?>"><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 -->
Re: [zick] Multi columns - code validation
By gkornbluth - June 22, 2011
Hi Zick,
If you got this code from the Cookbook I think that I may have led you astray...
Here's some code that I know works cause I copied it from a working web site of mine.
I've also updated the Cookbook recipe.
Hope it works better for you. Let me know what you find.
Jerry
If you got this code from the Cookbook I think that I may have led you astray...
Here's some code that I know works cause I copied it from a working web site of mine.
I've also updated the Cookbook recipe.
Hope it works better for you. Let me know what you find.
Jerry
<table border="0" id="gallery" cellspacing="0" cellpadding="10" align="center">
<tr valign="middle">
<?php foreach ($reflectionsRecords as $record): ?><?php foreach ($record['image'] as $upload): ?>
<td align="center" valign="middle" <?php echo $common_informationRecord['thumbnail_border'] ?> width="15%">
<div align="center">
<a href="<?php echo $upload['thumbUrlPath3'] ?>" rel="milkbox[reflections]" title="
<?php if (!$record['print_price'] && !$record['full_description']): ?><?php if ($record['title']): ?><a href="#"><h2><?php echo $record['title'] ?><br /><?php echo $record['sub_title'] ?></h2></a><br><?php endif ?>
<?php if (!$record['title']): ?><a href="<?php echo $record['_link'] ?>"><h2>Click for a larger image.</h2></a><?php endif ?><?php endif ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight']?>" /></a>
</div></td>
<?php $maxCols=7; if (@++$count % $maxCols == 0): ?></tr><tr><?php endif; ?>
<?php endforeach ?>
<?php endforeach ?>
</tr>
</table>
The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php