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
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
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.
interactivetools.com
php count
By matrix - March 8, 2008
<?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.
Re: [matrix] php count
By Dave - March 8, 2008
<?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. :)
interactivetools.com
Re: [Dave] php count
By matrix - March 8, 2008
Thank you so much.