/    Sign up×
Community /Pin to ProfileBookmark

using page break in while loop

Hi,

I have 10 records in a database and need to add a page break after every 3 records. I have a while loop to display all records but do not know how to implement the page break.
Can someone kindly advise? Thanks.

<p style=”page-break-before: always”>

==============
$sql=”select * from tablea”;
$result=$conn->query($sql);
<table>
while($row=$result->fetch_assoc()){
<tr><td>$row[“a”];</td></tr>
<tr><td>$row[“b”];</td></tr>
<tr><td>$row[“c”];</td></tr>
<tr><td>$row[“d”];</td></tr>
}
</table>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@rootOct 16.2018 — Use modulo a 3 counter to put a break whenwerve a number matches a 3 step.

eg. if( $itemCount % 3 == 0 ){
echo "&lt;br/&gt;" . PHP_EOL;
}


I'sure you can work it out.
×

Success!

Help @holy24 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 5.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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