Formatting display for Columns & Rows

5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 8, 2008   (RSS)

By BigBear - March 6, 2008 - edited: March 6, 2008

Hi Dave,

Simple simon here again.. lol

How do I go about placing data in a 4 x 3 table in the order that it comes up.

Is this done with the program, or is this a CSS or Html thing?

Thanks
Rob

Re: [BigBear] Formatting display for Columns & Rows

By Dave - March 6, 2008

Hi Rob,

Thanks for posting to the forum. I responded by email but here's the same response for anyone else who wants to do the same:

The first step is creating a mockup table of how you want it to look.

Next have it output all the listings and you could use some PHP code like this to insert something every X items.

<?php $maxCols=3; if (++$count % $maxCols == 0): ?>
<br/>
<?php endif ?>

So say you have a table, and you want to display 3 records one after another, then close and open a table cell with: </td><td valign="top"> You'd use:

<?php $maxCols=3; if (++$count % $maxCols == 0): ?>
</td><td align="top">
<?php endif ?>

Give it a try and let me know how it goes. If you get stuck just post the url to your mockup table and your test page and we'll help you out.
Dave Edis - Senior Developer
interactivetools.com

php count

By matrix - March 8, 2008

Using your suggestion as a way to get thumbnails to write in 2 column rows as follows:
<?php $maxCols=2;
if (++$count % $maxCols == 0): ?>
</td><td align="top"><?php endif ?>

Looks like it's working okay, but this error message precedes it, which sorta kills the effect [;)] :
"Notice: Undefined variable: count in /home/web/public_html/interior.php on line 89"

Is there some place $count is supposed to be defined as a variable? If so, where and how, please?

Sorry about this second question du jour, but am closing in on what's turned out to be a more difficult goal with CMS Builder than I had anticipated. Looking good, at least up to the error message.

Many, many thanks for your help.
Happy Interactive Tools product user since 1999

Re: [matrix] php count

By Dave - March 8, 2008

Try adding a @ before the ++ like this:

<?php $maxCols=2;
if (@++$count % $maxCols == 0): ?>
</td><td align="top"><?php endif ?>


And that should fix it. In PHP putting the @ symbol in front of something means "don't show error messages for this". Another way would have been to define count at the top of your page like this: <?php $count = 0; ?> but I'd just use the @ as it keeps everything in one place and makes for less code to keep track of.

Hope that helps, any other questions just let me know. :)
Dave Edis - Senior Developer
interactivetools.com