
Rusty
User
Feb 17, 2011, 6:11 AM
Post #15 of 17
(2641 views)
Shortcut
|
|
Re: [Jason] 3 coloumns listing + some more...
[In reply to]
|
Can't Post
|
|
I want to know why putting this within a foreach to list records (w/ a limit of 3 set within the table query) this works: THIS WORKS
<?php $maxCols=3; if (@++$count % $maxCols == 0): ?><div class="plan_box last"> <?php else: ?><div class="one_third"><?php endif; ?> THIS WORKS Properly assigning DIV "one_third" to the first two div's, and then "plan_box last" to the third and final div. But this:
<?php $counter = 0; while ( $counter <= 1 ) { echo "<div class=\"one_third\">"; $counter = $counter + 1; } echo "<div class=\"plan_box last\">"; ?>
makes all kinds of mumbo jumbo madness, doing what I want, but three times for each item listed within the FOREACH:
<div class="one_third"><div class="one_third"><div class="plan_box last"> It's not that I don't love the fact that I finally hammered this out, however, I just wish I knew what was going on with the % where it's checking to see if $maxCols is equal to zero. I see the IF statement, I see the @ sign (to suppress errors/warnings) I see the counter, but to me it seems backwards. Someone care to fill me in on the steps that are happening there? BTW that works awesome, and will be very useful for defining custom CSS for the last item in a particular list (when used within a FOREACH). Keywords I used to search. php counter auto increment list foreach multiple columns limit Rusty
(This post was edited by Rusty on Feb 17, 2011, 6:12 AM)
|