Forcing columns in multi row tables

7 posts by 2 authors in: Forums > CMS Builder
Last Post: January 28, 2009   (RSS)

Hi again,

Hope someone can help.

All of the posts that I could find deal with rows of single cells repeating after a number of columns.

I'm trying to get a set of 2 rows to repeat after 2 columns and for some reason I can’t seem to find the magic. (I know that I’m going to feel really dumb when I see what’s wrong)

Thanks,

Jerry Kornbluth

Here’s the single cell solution that works: http://www.marshazart.com/glassart3.php

<table width="100%" border="0" cellpadding="10">
<tr>
<?php foreach ($glass_artRecords as $record): ?><?php foreach ($record['image'] as $upload): ?>
<td align="center" valign="middle" width="50%"><img src="<?php echo $upload['thumbUrlPath2'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt="" />
<div class="medium-title"><?php echo $record['title'] ?></div>
<div class="medium-text"><?php echo $record['sub_title'] ?></div>
</td>
<?php $maxCols=2; if (@++$count % $maxCols == 0): ?></tr><tr><?php endif; ?>
<?php endforeach ?><?php endforeach ?>
</tr>
</table>

Here’s what I’ve tried for the 2 row solution that doesn’t work (the sets of rows don’t appear under each other): http://www.marshazart.com/glassart4.php

<table width="100%" border="0" cellpadding="10">
<tr>
<?php foreach ($glass_artRecords as $record): ?><?php foreach ($record['image'] as $upload): ?> <td align="center" valign="middle" width="50%"><img src="<?php echo $upload['thumbUrlPath2'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt="" />
</td><tr></tr><td>
<div class="medium-title"><?php echo $record['title'] ?></div>
<div class="medium-text"><?php echo $record['sub_title'] ?></div>
</td>
<?php $maxCols=2; 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

Re: [gkornbluth] Forcing columns in multi row tables

By Dave - January 27, 2009

Hi Jerry,

Can you create a quick mockup url so I can see what it's suppose to look like? Once I can see that I should have a better idea.

Thanks! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Forcing columns in multi row tables

Thanks Dave,

Here's the html mockup.

http://www.marshazart.com/glassart5.php

it's essentially the same as the glassart4.php cms version mentioned above

I wanted to use sets of 2 rows so that the alignment of the images and the alignment of the titles and other text were independent and lined up evenly regardless of the image heights.

Jerry
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

Re: [Dave] Forcing columns in multi row tables

Thanks for taking the time to respond Dave,

The table within a table approach sounds feasible. since I'd like not to limit the number of images.

Not sure how you would approach it though. How would it alter the PHP code above?

Thanks

Jerry
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

Re: [gkornbluth] Forcing columns in multi row tables

By Dave - January 28, 2009

Hi Jerry,

Maybe something like this:

<td align="center" valign="middle" width="50%">

<table border="1" cellspacing="0" cellpadding="0">
<tr><td>
<img src="<?php echo $upload['thumbUrlPath2'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt="" />
</td></tr>
<tr><td>
<div class="medium-title"><?php echo $record['title'] ?></div>
<div class="medium-text"><?php echo $record['sub_title'] ?></div>
</td></tr>
</tr></table>

</td>


And you'd probably want a fixed height on the td with the thumbnail so they all line up the same.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Forcing columns in multi row tables

It worked perfectly.

Thanks

Jerry
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