/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] In Loop Repeat ; Create <hr> after 5 records

Hello,

I have the following standard repeat:

[code=php] <?php do { ?>
<img src=”/_data/gallery/<?php echo $row_Photos[‘AID’]; ?>/thumb_<?php echo $row_Photos[‘Filename’]; ?>” />
<?php } while ($row_Photos = mysql_fetch_assoc($Photos)); ?> [/code]

As you can tell it just repeats images. What I would love to be able to do is after every 5 images create a <hr> or a break in the line of images to add a ‘image divider’

How do I go about doing this?

Thanks in advance!

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@cinematic_jesiauthorJul 23.2009 — Ok - I figured out how to count the images putting this just inside the bracket before the while() .. maybe this will help me?

[code=php]$ImageCounter++; [/code]
Copy linkTweet thisAlerts:
@cinematic_jesiauthorJul 23.2009 — Ok - so I have this, but the first time it adds a break it adds one too many??
[code=php] <?php do {

if ($ImageCounter==7) {
echo '<hr>';
$ImageCounter=1;
}
?>
<img src="/_data/gallery/<?php echo $row_Photos['AID']; ?>/thumb_<?php echo $row_Photos['Filename']; ?>" />
<?php $ImageCounter++; } while ($row_Photos = mysql_fetch_assoc($Photos)); ?> [/code]
Copy linkTweet thisAlerts:
@sushiJul 23.2009 — [code=php]
if($ImageCounter%5==0){
print "<hr/">;
}
[/code]
Copy linkTweet thisAlerts:
@MindzaiJul 23.2009 — [COLOR="White"]&#37;[/COLOR][code=php]
<?php $i = 0; while ($row_Photos = mysql_fetch_assoc($Photos)): ?>
<img src="/_data/gallery/<?php echo $row_Photos['AID']; ?>/thumb_<?php echo $row_Photos['Filename']; ?>" />
<?php if ($i++ % 5 == 0) echo '<hr />' ?>
<?php endwhile ?>[/code]
Copy linkTweet thisAlerts:
@cinematic_jesiauthorJul 23.2009 — Ohhhhh! I've never seen the &#37; used.. works! Thanks Sushi :]!!
Copy linkTweet thisAlerts:
@cinematic_jesiauthorJul 23.2009 — Thanks for another method of use Mindzai! :]!
Copy linkTweet thisAlerts:
@cinematic_jesiauthorJul 23.2009 — Ok - Quick question, for Sushi's method: how do I make it so the hr won't show above the first line, and only the lines thereafter?
Copy linkTweet thisAlerts:
@cinematic_jesiauthorJul 23.2009 — On nevermind, i just put the counter after the do and moved the if statement to before end bracket.. duh!
×

Success!

Help @cinematic_jesi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...