PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
P.S. This issue makes me feel like a bad programmer..... I know I'm not but I can NEVER understand this concept.... so if anyone has some good material to read that can help me understand issues similar to these I would really enjoy reading them.
Last edited by DaveTheAve on Sun Jul 15, 2007 11:55 am, edited 5 times in total.
<div id='photoalbum'>
{* start a looping section named i *}
{section name=i loop=$pictures}
{* If the iteration index is divisible by five, open a div *}
{* We are going to call this div 'thinborder' *}
{* This will only be opened if the iteration index is divisible by five *}
{* Otherwise it will show now opening div *}
{if $smarty.section.i.iteration % 5 == 1}
<div class='thinborder'>
{/if}
/uploads/photoalbums/{$album.album_id}/{$pictures[i][0]}
{* If the iteration index is divisible by 4, output a closing div *}
{* Logically, since this iteration index check is not the same *}
{* as the opening iteration index above, these two are totally unrelated *}
{if $smarty.section.i.iteration % 4 == 1}
</div>
{/if}
{/section}
</div>
The only reason why those two are 5 & 4 is because if they where both the same it would OPEN & CLOSE the new div including ONLY ONE picture not the full five.
DaveTheAve wrote:The only reason why those two are 5 & 4 is because if they where both the same it would OPEN & CLOSE the new div including ONLY ONE picture not the full five.
Huh?
It is looping the entire set of data and throwing that data to the screen. If you want every fifth iteration to show something, then show it per 5th iteration.
I see what you want to do. You need to open the div at five and close it at 10, or the last record, if the last record index of the current group is less than 10.
Thank you guys, I'm currently off to a bible-study, thus i can't test any of your code. However, I that last segment of code looks exactly like what i need. Thank you guys!
P.S. In the credits of this free, open-source project PHPDN will be there!
I believe that if you want to check to see if x is evenly divisible by y, it's x%y==0.
By saying i%5==1, you are saying, if i divided by 5 leaves a remainder of 1, do this.
Try changing the 1 to 0 and see what it does.